标签:ios uitabbarcontroller 隐藏bottombar
先自定义一个UITabbarController,用于Storyboard中
再在MyTabbarController中实现protocol
@interface MyTabbarController : UITabBarController <UITabBarControllerDelegate> @end再实现代理里面的方法
@implementation MyTabbarController - (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController { NSLog(@"shouldSelectViewController %@", tabBarController.selectedViewController); if (viewController.tabBarItem.tag == 100) { DiaryViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:DIARY_VC_ID]; [((UINavigationController *)tabBarController.selectedViewController) pushViewController:vc animated:YES]; return NO; } return YES; } - (id)initWithCoder:(NSCoder *)aDecoder { self = [super initWithCoder:aDecoder]; if (self) { self.delegate = self; } return self; } @end在要监听的tabbaritem跳转的viewcontroller中(比如点击一个item隐藏tabbar,而且有返回按钮)
则找到该tabbar,我的是父控件的tabbar,所以
- (void)viewWillAppear:(BOOL)animated { self.parentViewController.tabBarController.tabBar.hidden = YES; }点击返回按钮后回到开始所选中的tabbaritem
- (void)viewWillDisappear:(BOOL)animated { self.parentViewController.tabBarController.tabBar.hidden = NO; }
IOS 点击tabbaritem跳转到一个新界面,且隐藏tabbar
标签:ios uitabbarcontroller 隐藏bottombar
原文地址:http://blog.csdn.net/fanxiaoxuan1234/article/details/41721635