【发布时间】:2017-06-06 14:37:48
【问题描述】:
我只想在父控制器上显示标签栏,而不是在任何子控制器上。
我正在推送:
childViewController?.hidesBottomBarWhenPushed = true
self.navigationController?.pushViewController(childViewController!, animated: true)
现在,当我通过单击“返回”按钮向后导航时,该栏再次显示在父级上。
但是如果我像这样以编程方式做同样的事情:
childViewController?.hidesBottomBarWhenPushed = true
self.navigationController?.popToRootViewController(animated: true)
//or
self.navigationController?.popViewController(animated: true)
然后标签栏不再显示在父级上。
我已经尝试了很多解决方案,例如;
解决方案 1: 用孩子写这段代码
- (void)viewWillAppear:(BOOL)animated {
self.hidesBottomBarWhenPushed = true
}
- (void)viewWillDisappear:(BOOL)animated {
self.hidesBottomBarWhenPushed = false
}
解决方案 2:在 push 上编写此代码
childViewController?.hidesBottomBarWhenPushed = true
self.navigationController?.pushViewController(childViewController!, animated: true)
childViewController?.hidesBottomBarWhenPushed = false
这些都不起作用。如果我使用导航栏后退按钮导航回来,一切正常。
但是如果我popViewController 或popToRootViewController 那就不行了。
使用:XCode 8.3.2、Swift 3
请帮帮我。提前谢谢你。
【问题讨论】:
标签: uitabbarcontroller popviewcontrolleranimated