iPhone 8:视图不会隐藏在导航栏下

时间:2018-04-05 18:08:43

标签: ios swift uinavigationbar ios11 iosdeployment

我搜索了所有问题,大部分开发人员都在询问如何解决视图隐藏在导航栏后面的问题,另一方面我想隐藏导航栏后面的视图但没有运气。

我有一个tableview,我希望从导航栏后面开始。

到目前为止,我试过了。

    self.navigationController?.navigationBar.isTranslucent = true
    self.extendedLayoutIncludesOpaqueBars = true
    self.edgesForExtendedLayout = .top

但是没有运气,我也尝试通过故事板启用,但这也没有做到。

添加屏幕截图

enter image description here

这是NavBar的检查员, enter image description here

这就是它的表现,

enter image description here

我们可以在栏后立即开始。

细胞层次结构, enter image description here

2 个答案:

答案 0 :(得分:0)

override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)

    // Hide the Navigation Bar
    self.navigationController?.setNavigationBarHidden(true, animated: animated)
}

override func viewWillDisappear(_ animated: Bool) {
    super.viewWillDisappear(animated)

    // Show the Navigation Bar
    self.navigationController?.setNavigationBarHidden(false, animated: animated)
}

答案 1 :(得分:0)

关键是如何固定视图的顶部。它必须固定在主视图的顶部 - 而不是顶部主视图边距,而不是安全区域/顶部布局指南。仔细看看这个屏幕截图:这是你的顶级约束必须看起来的样子:

enter image description here

当应用程序运行时,视图会在导航栏下面显示,就像Interface Builder中所示:

enter image description here

相关问题