27
votes

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!

5

5 Answers

67
votes

use this methood in the UIViewController class where you want to hide the tabBarController

-(BOOL)hidesBottomBarWhenPushed
{
    return YES;
}

Update

As suggested by @Yuchen Zhong in his answer, This option is now available in the storyboard itself.

enter image description here

20
votes

You can do this in storyboard now:

  1. Select the UIViewController in your storyboard
  2. Select the checkbox Hide Bottom Bar on Push

enter image description here

12
votes

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

nextViewController.hidesBottomBarWhenPushed = YES;
4
votes

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

Instead I hide the tabbar in viewDidLoad with

self.tabBarController.tabBar.hidden = YES;

and restore its presence in viewWillDisappear

self.tabBarController.tabBar.hidden = NO;
1
votes

Set true hidesBottomBarWhenPushed in the controller that you want to hide.

For hide all controllers put into prepare for segue

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
    segue.destination.hidesBottomBarWhenPushed = true
}