在 CollectionView 中滚动 tableView 时隐藏 NavigationBar? [英] Hide NavigationBar when scrolling tableView in CollectionView?

查看:26
本文介绍了在 CollectionView 中滚动 tableView 时隐藏 NavigationBar?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有 collectionViewController 和 collectionViewCell 包括 TableView.CollectionView 是水平布局.我想在滚动 tableView 时隐藏导航栏.对此有什么想法吗.

I have collectionViewController and collectionViewCell include TableView.CollectionView is horizontal layout.I want hide navigationbar when scroll the tableView. Is there any idea about that.

推荐答案

从 iOS 8 开始就可以使用

Since iOS 8 you can just use

self.navigationController?.hidesBarsOnSwipe = true

这当然需要您的 ViewController 嵌入在 NavigationController 中.NavigationController 的所有子 VC 都将继承此行为,因此您可能希望在 viewWillAppear 中启用/禁用它.您还可以在情节提要中的导航控制器上设置相应的标志.

This requires of course that your ViewController is embedded in a NavigationController. All child VC of the NavigationController will inherit this behaviour, so you might want to enable/disable it in viewWillAppear. You can also set the respective flags on the navigation controller in the storyboard.

这篇关于在 CollectionView 中滚动 tableView 时隐藏 NavigationBar?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆