[英]Nav Bar not hiding
For some reason, my bottom nav bar is not hiding on my main view controller (blue screen in the following storyboard): 由于某种原因,我的底部导航栏没有隐藏在主视图控制器上(以下情节提要中的蓝屏):
I do not want a tab bar to display on the bottom of the blue screen, so I've put in the following code in its view controller: 我不希望选项卡栏显示在蓝色屏幕的底部,因此我将以下代码放入其视图控制器中:
override func viewWillAppear(animated: Bool) {
self.navigationController?.setToolbarHidden(true, animated: animated)
self.navigationController?.setNavigationBarHidden(true, animated: animated)
super.viewWillAppear(animated)
}
override func viewWillDisappear(animated: Bool) {
self.navigationController?.setToolbarHidden(false, animated: animated)
self.navigationController?.setNavigationBarHidden(false, animated: animated)
super.viewWillDisappear(animated)
}
It top navigation bar is not displaying (as expected), but the bottom bar is not hiding. 它的顶部导航栏未显示(按预期方式),但底部栏未隐藏。 It's also displaying twice on every screen thereafter (see screenshot below): 此后,它还在每个屏幕上显示两次(请参见下面的屏幕截图):
Is it because I have a Tab Bar Controller in my interface builder? 是因为我的界面生成器中有一个标签栏控制器吗? Is there a way to implement the tab bar controller with four icons programmatically instead? 有没有办法以编程方式实现带有四个图标的标签栏控制器? The only screen that I really want the tab bar controller to be on is the Table View. 我真正希望打开选项卡栏控制器的唯一屏幕是“表视图”。
Use hidesBottomBarWhenPushed
在hidesBottomBarWhenPushed
使用hidesBottomBarWhenPushed
In the view controller with blue background color: 在具有蓝色背景色的视图控制器中:
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if let desVC: UIViewController = segue.destinationViewController as? UIViewController {
desVC.hidesBottomBarWhenPushed = true
}
}
删除此行self.navigationController?.setToolbarHidden(true, animated: animated)
和TextField
顶部连接(安全区域)更改Superview
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.