导航: 状态栏 隐藏(hidesBottomBarWhenPushed)

2016-12-16 09:13:19.318 TheStep[1159:150589] *** 
Terminating app due to uncaught exception 'NSInvalidArgumentException', 
reason: 
'Pushing a navigation controller is not supported'


之前

@interface DiscoverViewController : UIViewController

我让他继承

正解:

UIViewController * viewController = [[NSClassFromString(objDictionary[kClass]) alloc ] init ];
        BaseItemNaviViewController * navigationViewController = [[BaseItemNaviViewController alloc ] 

在 MainTabBarController 里面改

就不用一个一个这样了

- (void)tapSearchBar
{
    SearchMessgViewController * searchMessgViewController = [[SearchMessgViewController alloc ] init ];
//    searchMessgViewController.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController: searchMessgViewController animated: YES ];


}


感谢
iOS+TabBar的隐藏,hidesBottomBarWhenPushed的正确使用

NavigationController重写push方法(学习小码哥的方法)

感谢

iOS:hidesBottomBarWhenPushed的正确用法

Case1:xib加载或者Storyboard用identifier获取Controller

UIViewController *v2 = [self.storyboard instantiateViewControllerWithIdentifier:@"v2"];
v2.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:v2 animated:YES];

Case2:拉线,也就是Storyboard用performSegue

self.hidesBottomBarWhenPushed = YES;
[self performSegueWithIdentifier:@"tov2" sender:nil];
self.hidesBottomBarWhenPushed = NO;

Tip:经测试证明,此种方式只会对后面的一级生效,继续往后Push还会出现TabBar,要继续往后push也隐藏Tabbar还得使用Case3的方法,也建议如此!

Case3:拉线,在prepareForSegue函数里

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    [segue.destinationViewController setHidesBottomBarWhenPushed:YES];
}

更方便的做法:如果你在用 Storyboard,可以在 ViewController 的设置面板中把 Hide Bottom Bar on Push 属性勾选上,效果和上文代码一样。

三种ViewController跳转的异同

你可能感兴趣的:(导航: 状态栏 隐藏(hidesBottomBarWhenPushed))