美文网首页
tabBar的隐藏与显示

tabBar的隐藏与显示

作者: 卞泽 | 来源:发表于2018-03-31 15:48 被阅读8次

页面A push 到页面B,需隐藏tabBar,页面 B pop 回到A 让tabBar再出现。

方法一:

在页面B的viewWillAppear里写 
self.tabBarController.tabBar.hidden = YES;

在页面A 的viewWillAppear里写
self.tabBarController.tabBar.hidden = NO;

注:不能在页面A的 viewDidLoad 方法里写这句代码。
因为 viewDidLoad 方法只执行一次,pop回到A的时候,这里面的代码不走了。

注:使用这种方法在页面B侧滑返回页面A是tabbar显示bug。

方法二:

在跳转的方法里写:
self.hidesBottomBarWhenPushed = YES;
    
UIViewController * vc = [[UIViewController alloc]init];
[self.navigationController pushViewController:vc animated:YES];
 
方法三:

比如方法二中push时,使用的是self.navigationController进行push。
因为self.navigationController是tabbarController的子控制器,所以才会有tabbar隐藏的问题。
所以解决方案就是用self.navigationController.parentViewController.navigationController进行push。

相关文章

网友评论

      本文标题:tabBar的隐藏与显示

      本文链接:https://www.haomeiwen.com/subject/bjepqftx.html