推送视图时如何隐藏tabBar?

时间:2022-07-10 02:49:15

My application is a Tabbed Appliaction, 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!

我的应用程序是Tabbed Appliaction,它在tabBarController下有几个控制器。一个控制器是navigationController,其根视图是表视图。当我单击表视图的一行时,将推入另一个视图。所以问题是当推入视图时,如何隐藏底部的tabBar?此外,我还想在推送视图中添加另一个tabBar,所以我需要分配一个UITabBar或UITabBarController?还是有另一种方式?谢谢!

4 个解决方案

#1


51  

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在他的回答中所建议的,这个选项现在可以在故事板中找到。

推送视图时如何隐藏tabBar?

#2


13  

You can do this in storyboard now:

您现在可以在故事板中执行此操作:

  1. Select the UIViewController in your storyboard
  2. 在故事板中选择UIViewController
  3. Select the checkbox Hide Bottom Bar on Push
  4. 选中“在推送时隐藏底栏”复选框

推送视图时如何隐藏tabBar?

#3


9  

Set UIViewController.hidesBottomBarWhenPushed = YES when you want hide tab bar.

如果要隐藏标签栏,请设置UIViewController.hidesBottomBarWhenPushed = YES。

...
nextViewController.hidesBottomBarWhenPushed = YES;
...

#4


5  

Sometimes the hidesBottomBarWhenPushed method hides the bottom bar with a choppy animation.

有时,hidesBottomBarWhenPushed方法会隐藏带有不稳定动画的底栏。

Instead I hide the tabbar in viewDidLoad with

相反,我隐藏了viewDidLoad中的tabbar

self.tabBarController.tabBar.hidden = YES;

and restore its presence in viewWillDisappear

并在viewWillDisappear中恢复其存在

self.tabBarController.tabBar.hidden = NO;

#1


51  

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在他的回答中所建议的,这个选项现在可以在故事板中找到。

推送视图时如何隐藏tabBar?

#2


13  

You can do this in storyboard now:

您现在可以在故事板中执行此操作:

  1. Select the UIViewController in your storyboard
  2. 在故事板中选择UIViewController
  3. Select the checkbox Hide Bottom Bar on Push
  4. 选中“在推送时隐藏底栏”复选框

推送视图时如何隐藏tabBar?

#3


9  

Set UIViewController.hidesBottomBarWhenPushed = YES when you want hide tab bar.

如果要隐藏标签栏,请设置UIViewController.hidesBottomBarWhenPushed = YES。

...
nextViewController.hidesBottomBarWhenPushed = YES;
...

#4


5  

Sometimes the hidesBottomBarWhenPushed method hides the bottom bar with a choppy animation.

有时,hidesBottomBarWhenPushed方法会隐藏带有不稳定动画的底栏。

Instead I hide the tabbar in viewDidLoad with

相反,我隐藏了viewDidLoad中的tabbar

self.tabBarController.tabBar.hidden = YES;

and restore its presence in viewWillDisappear

并在viewWillDisappear中恢复其存在

self.tabBarController.tabBar.hidden = NO;