我要
View Controller 1:显示标签栏
View Controller 2:显示标签栏
View Controller 3:未显示标签栏。
我写了
// prepareForSegue in view controller 1,
let upcoming = segue.destinationViewController as! viewcontroller3
upcoming.hidesBottomBarWhenPushed = true
// prepareForSegue in view controller 3,
let upcoming = segue.destinationViewController as! viewcontroller2
self.hidesBottomBarWhenPushed = true
当我从 View Controller 1 转到 View Controller 3 时,标签栏没有显示。然后,我从 View Controller 3 转到 View Controller 2,显示了选项卡栏。 但是当我在 View Controller 2 中点击返回时,标签栏显示在 View Controller 3 中。 self.hidesBottomBarWhenPushed = true
对我来说没有意义。但是,我不知道我应该怎么做才能解决这个问题。有什么建议么?谢谢。
最佳答案
隐藏标签栏的方法是 - 在你插入下一个 View Controller 的地方这样做:
self.hidesBottomBarWhenPushed = true
self.navigationController?.pushViewController(controllerToPush, animated: true)
self.hidesBottomBarWhenPushed = false
这将确保标签栏对于推送的 View 是隐藏的,并且当您弹出时该栏将再次显示。没有后退按钮逻辑,没有 viewDidLoad 或类似的东西,没有别的。这应该足够了。
同样适用于 objective-c
现在 ( 21/02/2018 ) 您还可以在 Storyboard 中为您不想显示底栏的每个 Controller 检查选项 强>。这将有助于清理代码,并且您不需要在您推送的 Controller 中设置任何内容。
关于ios - 如何在按下时隐藏标签栏并在返回时显示标签栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35425134/