UITabBarController与UINavigationController异同点浅谈
来源:互联网 发布:战争程序员白濑 动漫 编辑:程序博客网 时间:2024/06/05 08:50
UITabBarController与UINavigationController都可以管理多个视图控制器,并且完成视图控制器的切换,并且UITabBarController中可以嵌套UINavigationController,UINavigationController中也可以嵌套UITabBarController
UITabBarController管理多个视图控制器(被管理的视图控制器是平级关系),通过TabBar上的标签切换显示被管理的controller的页面,而UINavigationController则是有上一个页面推出下一个页面
以微信作为例子,在UITabBarController中可以嵌套UINavigationController
//创建被tabVC管理的视图控制器 //微信 VchatViewController *vVC = [[VchatViewController alloc] init]; UINavigationController *nav1 = [[UINavigationController alloc] initWithRootViewController:vVC]; vVC.navigationItem.title = @"微信"; //标签标题 vVC.tabBarItem.title = @"微信"; //设置图片 vVC.tabBarItem.image = [UIImage imageNamed:@"08-chat.png"]; //标签栏标记 vVC.tabBarItem.badgeValue = @"5"; //通讯录 AddressBookViewController *addVC = [[AddressBookViewController alloc] init]; UINavigationController *nav2 = [[UINavigationController alloc] initWithRootViewController:addVC]; addVC.navigationItem.title = @"通讯录"; addVC.tabBarItem.title = @"通讯录"; addVC.tabBarItem.image = [UIImage imageNamed:@"24-gift.png"]; //发现 DiscoverViewController *disVC = [[DiscoverViewController alloc] init]; UINavigationController *nav3 = [[UINavigationController alloc] initWithRootViewController:disVC]; disVC.navigationItem.title = @"发现"; disVC.tabBarItem.title = @"发现"; disVC.tabBarItem.image = [UIImage imageNamed:@"06-magnifying-glass.png"]; disVC.tabBarItem.badgeValue = @"8"; //我 MeViewController *meVC = [[MeViewController alloc] init]; UINavigationController *nav4 = [[UINavigationController alloc] initWithRootViewController:meVC]; meVC.navigationItem.title = @"我"; meVC.tabBarItem.title = @"我"; meVC.tabBarItem.image = [UIImage imageNamed:@"29-heart.png"]; //设置 SettingViewController *setVC = [[SettingViewController alloc] init]; UINavigationController *nav5 = [[UINavigationController alloc] initWithRootViewController:setVC]; setVC.navigationItem.title = @"设置"; setVC.tabBarItem.title = @"设置"; setVC.tabBarItem.image = [UIImage imageNamed:@"19-gear.png"]; // //登陆// LoginViewController *logVC = [[LoginViewController alloc] init];// logVC.tabBarItem.title = @"登陆";// logVC.tabBarItem.image = [UIImage imageNamed:@"38-airplane.png"]; //设置TabBar管理的controller //当controller超过5个的时候,刺痛会自动增加哦一个”more“标签,管理第五个和五个以上的controller,没有出现在底部的controller会以列表的形式通过点击more展示出来 tabVC.viewControllers = @[nav1, nav2, nav3, nav4, nav5]; //设置tabBarController代理 tabVC.delegate = self;所显示的页面是
当点击某一个标签时,便会切换到标签对应的页面
UINavigationController的推出视图的方法是:这是由当前页面推出ThreeViewController控制的页面
- (void)goToNextVC:(UIButton *)btn{ ThreeViewController *threeVC = [[ThreeViewController alloc] init]; [self.navigationController pushViewController:threeVC animated:YES];}
返回上一个页面
- (void)goBackPreviousVC:(UIButton *)btn1{ [self.navigationController popViewControllerAnimated:YES];}
以上所述只是对两者浅显的对比,我会继续研究的
0 0
- UITabBarController与UINavigationController异同点浅谈
- UINavigationController与UITabBarController
- UINavigationController与UITabBarController
- UINavigationController与UITabBarController
- UINavigationController与UITabBarController
- UITabBarController与UINavigationController配合使用
- UINavigationController与UITabBarController混合使用
- UITabBarController与UINavigationController配合使用
- UITabBarController与UINavigationController配合使用
- UITabBarController与UINavigationController配合使用
- UINavigationController与UITabbarController的样式
- UINavigationController,UITabBarController
- UINavigationController, UITabBarController
- UINavigationController+UITabBarController
- UINavigationController、UITabBarController
- iOS之UINavigationController与UITabBarController的使用
- UINavigationController,UIViewController与UITabBarController的整合使用
- iOS UINavigationController与UITabBarController的组合使用
- Android 反射Method应用
- 目前状态
- 关于awakeFromNib的学习
- C-055.自己用C语言写的一个正整数的十进制转二进制的代码
- Java中异或运算实现两个整数的交换以及其功能函数实现
- UITabBarController与UINavigationController异同点浅谈
- Triangle Count算法
- POJ 1681 (高斯消元)
- 【openjudge】集合问题
- 百度地图自定义图层----BMapTileCutterJava切图工具网络版
- hdu4864 贪心+平衡二叉搜索树(map)
- 机器学习Python环境安装
- coderforce 489B B. BerSU Ball
- lightoj 1043 - Triangle Partitioning