[英]How to hide the tabBar when push a view?
My application is a Tabbed Application, and it have several controllers under the tabBarController.我的应用程序是一个选项卡式应用程序,它在 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?当我点击表格视图的一行时,另一个视图会被推入。所以问题是,当视图被推入时,如何隐藏底部的tabBar? Besides, I also want to add another tabBar into the pushed view, so I need to alloc a UITabBar or UITabBarController?另外,我还想在推送视图中添加另一个tabBar,所以我需要分配一个UITabBar或UITabBarController? Or there is another way?或者还有别的方法吗? Thank you!谢谢!
use this methood in the UIViewController class where you want to hide the tabBarController在要隐藏 tabBarController 的 UIViewController 类中使用此方法
-(BOOL)hidesBottomBarWhenPushed
{
return YES;
}
Update更新
As suggested by @Yuchen Zhong in his answer, This option is now available in the storyboard itself.正如@Yuchen Zhong 在他的回答中所建议的,这个选项现在在故事板本身中可用。
当你想隐藏标签栏时,设置UIViewController.hidesBottomBarWhenPushed = YES
。
nextViewController.hidesBottomBarWhenPushed = YES;
Sometimes the hidesBottomBarWhenPushed method hides the bottom bar with a choppy animation.有时, hidesBottomBarWhenPushed 方法会隐藏带有断断续续动画的底部栏。
Instead I hide the tabbar in viewDidLoad with相反,我隐藏了 viewDidLoad 中的标签栏
self.tabBarController.tabBar.hidden = YES;
and restore its presence in viewWillDisappear并恢复它在 viewWillDisappear 中的存在
self.tabBarController.tabBar.hidden = NO;
Set true
hidesBottomBarWhenPushed
in the controller that you want to hide.在要隐藏的控制器中设置true
hidesBottomBarWhenPushed
。
For hide all controllers put into prepare for segue
隐藏所有控制器prepare for segue
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
segue.destination.hidesBottomBarWhenPushed = true
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.