如何在推送视图时隐藏 tabBar?
我的应用程序是一个选项卡式应用程序,它在 tabBarController 下有几个控制器。一个控制器是一个navigationController,它的根视图是一个表视图。当我单击表视图的一行时,将推入另一个视图。 那么问题来了,当view推入的时候,如何隐藏底部的tabBar呢? 另外,我还想在推送视图中添加另一个tabBar,所以我需要分配一个UITabBar或UITabBarController?或者还有别的办法吗?谢谢你!
My application is a Tabbed Application, and it have several controllers under the tabBarController. One controller is a navigationController, and its root view is a table view. When I click a row of the table view, another view will be pushed in.
So the question is that when the view is pushed in, how can I hide the tabBar at the bottom?
Besides, I also want to add another tabBar into the pushed view, so I need to alloc a UITabBar or UITabBarController? Or there is another way? Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
在要隐藏 tabBarController
Update
的 UIViewController 类中使用这种方法正如 @Yuchenzhong 在他的回答中所建议的,这个选项现在在故事板本身中可用。
use this methood in the UIViewController class where you want to hide the tabBarController
Update
As suggested by @Yuchen Zhong in his answer, This option is now available in the storyboard itself.
您现在可以在故事板中执行此操作:
You can do this in storyboard now:
当你想隐藏标签栏时,设置
UIViewController.hidesBottomBarWhenPushed = YES
。Set
UIViewController.hidesBottomBarWhenPushed = YES
when you want hide tab bar.有时, hidesBottomBarWhenPushed 方法会隐藏带有断断续续的动画的底部栏。
相反,我隐藏 viewDidLoad 中的选项卡栏
并在 viewWillDisappear 中恢复其存在
Sometimes the hidesBottomBarWhenPushed method hides the bottom bar with a choppy animation.
Instead I hide the tabbar in viewDidLoad with
and restore its presence in viewWillDisappear
在要隐藏的控制器中设置
true
hidesBottomBarWhenPushed
。为了隐藏所有放入
准备segue
的控制器Set
true
hidesBottomBarWhenPushed
in the controller that you want to hide.For hide all controllers put into
prepare for segue