iOS 隐藏tabBar UITabBarController 以及 于UINavigationController 配合使用 push
来源:互联网 发布:win7 apache php 配置 编辑:程序博客网 时间:2024/06/05 13:35
关于隐藏tabBar底部的导航,模仿微信做法,主要用于方便在单独的页签可以一直push到下一个UIViewController;
布局:首先为一个UITabBarController
UITabBarController *tabBarController = [[UITabBarController alloc] init];
为tabBar增加4个对应的View;我们选择位UINavigationController ;
<pre name="code" class="objc">UITabBarController *tabBarController = [[UITabBarController alloc] init]; UserListViewController *userListVC = [[UserListViewController alloc] init]; DishListViewController *dishListVC = [[DishListViewController alloc] init]; FriendListController *friendListVC = [[FriendListController alloc] init]; WCIndexViewController *indexVC = [[WCIndexViewController alloc] init]; indexVC.title = @"index"; indexVC.tabBarItem = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemDownloads tag:1]; [indexVC.tabBarItem setBadgeValue:@"1"]; // indexVC.tabBarItem sett userListVC.tabBarItem = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemFavorites tag:2]; userListVC.title = @"user"; dishListVC.tabBarItem = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemSearch tag:5]; dishListVC.title = @"user"; friendListVC.tabBarItem = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemContacts tag:4]; friendListVC.title = @"friend"; SJFanViewController *sjVC = [[SJFanViewController alloc] init]; UINavigationController *second = [[UINavigationController alloc] initWithRootViewController:sjVC]; second.title = @"second"; second.tabBarItem =[[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemSearch tag:5]; second.tabBarItem.title = @"second"; UINavigationController *third = [[UINavigationController alloc] initWithRootViewController:userListVC]; third.title = @"third"; third.tabBarItem =[[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemSearch tag:5]; UINavigationController *fourth = [[UINavigationController alloc] initWithRootViewController:friendListVC]; fourth.title = @"fourth"; NSArray *views = [NSArray arrayWithObjects: indexVC, second,third,fourth, nil]; //设置tabBar Item View [tabBarController setViewControllers:views animated:YES]; //默认显示哪个一个ViewController [tabBarController setSelectedIndex:3]; tabBarController.tabBar.tintColor = [UIColor whiteColor]; //设置tabBar背景 tabBarController.tabBar.backgroundColor = [UIColor purpleColor];
-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{// NSLog(@"%d",indexPath.row); if(indexPath.section ==0){ NSLog(@"section 1"); //把当前页签设置push监控, 如果push,那么则隐藏tabBar导航栏 self.hidesBottomBarWhenPushed = YES; UserInfoViewController *userInfo = [[UserInfoViewController alloc] init]; [self.navigationController pushViewController:userInfo animated:YES]; }else if (indexPath.section == 1){ } }
那么进入UserInfoController 之后,tabBar则隐藏了不会再现实出来,当点击back至前一个页面,tabBar也不会显示,我们得想办法让它显示出来;
则需要在当前的页面
-(void) viewWillDisappear:(BOOL)animated{ self.hidesBottomBarWhenPushed = NO;}
主要是这句:
self.hidesBottomBarWhenPushed = YES;
和
self.hidesBottomBarWhenPushed = NO;
0 0
- iOS 隐藏tabBar UITabBarController 以及 于UINavigationController 配合使用 push
- iOS使用UITabbarController跳转(push)界面,如何自动隐藏底部tabbar?
- UITabBarController与UINavigationController配合使用
- UITabBarController与UINavigationController配合使用
- UITabBarController与UINavigationController配合使用
- UITabBarController与UINavigationController配合使用
- IOS研究之UITabBarController隐藏tabBar以及addChildViewController
- UITabBarController和UINavigationController结合使用的情况下,如何隐藏tabBar?
- tabbar在UITabbarController和UINavigationController中的显示,隐藏问题
- UITabBarController + UINavigationController 框架相关问题(隐藏TabBar)
- ios中由UITabbar管理的UINavigationController当push的时候隐藏TabBar
- iOS使用push隐藏子页面底部bottom TabBar
- iOS使用push隐藏子页面底部bottom TabBar
- ios更改UITabBarController背景以及选中背景图片的方法 以及隐藏tabbar
- 隐藏UINavigationController和UITabBarController
- 隐藏UITabBarController的tabBar
- iOS push时 tabbar隐藏的问题
- [iOS] TabBarController push后隐藏TabBar
- 求两人生日相差多少天
- win7系统无法激活问题
- 冒烟测试
- Ubuntu下用Hexo搭建个人博客及常见问题的解决方案
- 开博写文
- iOS 隐藏tabBar UITabBarController 以及 于UINavigationController 配合使用 push
- BlockingQueue详解
- Leetcode Wildcard Matching
- 同步时钟脚本在crontab中遇到的问题
- linux shell中各种括号的使用方法
- 科大少年班“神童”是先戴博士帽,还是先戴乌纱帽?
- hdu_1002_Let the Balloon Rise (模拟)
- 科大少年班“神童”是先戴博士帽,还是先戴乌纱帽?
- stm8 红外解码 使用TL IO中断与定时实现(芯片用103)