当用户在 swift 中滚动 table 视图时如何隐藏和取消隐藏导航栏?
how to hide and unhide navigation bar when user scroll the table view in swift?
我已经读过这个帖子Hide NavigationBar when scrolling tableView in CollectionView?
但我还是得不到我想要的。我知道有一个 pod 可以做到这一点,但我尽量避免使用 pod。
我想在用户向下滚动 table 视图时隐藏导航栏,而当用户向上滚动回到顶部时我想隐藏导航栏。就像在 App Store 的 "today" 栏中一样。
我试过用
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.navigationController?.hidesBarsOnSwipe = true
}
当我向下滚动table视图时它可以隐藏导航栏,但是当我向上滚动回到顶部时,导航栏仍然消失。
你可以在这里看到我无法取消隐藏导航栏的 .gif 文件:http://g.recordit.co/zIW2DkCc6j.gif
这是我的 table 观点的限制
我该怎么办?或者你有其他代码?请分享 :)
好的。你所做的是正确的(在代码中)。只需将 table 视图的顶部约束更改为以下内容:
我已经读过这个帖子Hide NavigationBar when scrolling tableView in CollectionView?
但我还是得不到我想要的。我知道有一个 pod 可以做到这一点,但我尽量避免使用 pod。
我想在用户向下滚动 table 视图时隐藏导航栏,而当用户向上滚动回到顶部时我想隐藏导航栏。就像在 App Store 的 "today" 栏中一样。
我试过用
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.navigationController?.hidesBarsOnSwipe = true
}
当我向下滚动table视图时它可以隐藏导航栏,但是当我向上滚动回到顶部时,导航栏仍然消失。
你可以在这里看到我无法取消隐藏导航栏的 .gif 文件:http://g.recordit.co/zIW2DkCc6j.gif
这是我的 table 观点的限制
我该怎么办?或者你有其他代码?请分享 :)
好的。你所做的是正确的(在代码中)。只需将 table 视图的顶部约束更改为以下内容: