hidesBottomBarWhenPressed在返回ViewController时没有设置
我有我的UIViewController(称为ViewControllerA)被推入到我的UINavigationController堆栈之一的hidesBottomBarWhenPushed = true设置。 我也select在ViewControllerA的ontop上显示bottomBar。 所以我有:
class ViewControllerA: UIViewController { override func viewWillDisappear(animated: Bool) { self.hidesBottomBarWhenPushed = false } override func viewWillAppear(animated: Bool) { self.hidesBottomBarWhenPushed = true }
这一切工作正常。
当我推ViewControllerA,底部栏隐藏。 当我推任何其他的ViewController,底部栏显示。
但是,当我在导航堆栈中向后行进(又名UIBarButtonItemBackbutton)时,popup导航堆栈以显示ViewControllerA时,无法隐藏bottomBar。
我错过了什么? 谢谢!
得到它了! 这是什么工作:
class ViewControllerCustom: UIViewController { init() { self.hidesBottomBarWhenPushed = true } override func viewDidAppear(animated: Bool) { self.hidesBottomBarWhenPushed = false } }
然后在每个UIViewController的BarButtonItemBackbutton的自定义实现中,我查看是否以前的视图控制器(将popup需要隐藏标签栏)。 当然,我把这个抽象成一个通用的函数,所以我不需要重复代码,但这里是概念。 感谢帮助搞清楚这一点!
func barButtonItemBackPressed(button: UIButton) { var viewControllers = self.navigationController!.viewControllers as! [UIViewController] if ((viewControllers[viewControllers.count - 2]).isKindOfClass(ViewControllerCustom.self)) { (viewControllers[viewControllers.count - 2] as! ViewControllerCustom).hidesBottomBarWhenPushed = true } self.navigationController?.popViewControllerAnimated(true) }
我相信这个属性的预期用途是推动时隐藏栏。 所以,当你的视图控制器出现在最顶层的popup窗口之后,它不会被压入堆栈,所以它不会改变标签栏的外观。
这给你两个select:
1)保留所有视图控制器的底部栏。 当input文本时,键盘覆盖底部栏。
2)隐藏视图控制器A的底部栏,以及在A顶部推动的任何其他视图控制器。