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!
Asked
Active
Viewed 2.3k times
5 Answers
67
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.

Bonnie
- 4,943
- 30
- 34
-
1Thanks! I used this method but it still did not work. I also used "myViewController.tabBarController.hidesBottomBarWhenPushe = YES", and it didn't work too. I'm confused about this. Do I need to change my structure or there are better ways? Thank you! – wjldxt Jan 03 '12 at 04:58
-
1I have a similar TabBar application with NavigationController as its 1st controller, but in the navigationController I have then only added a tableView, and push the other view's in didSelectRow methood of the table view. have you taken tableVeiwController instead a simple tableView..?? would be helpful if you paste some of your code here – Bonnie Jan 03 '12 at 05:46
-
1Thank you! I did it eventually. It's my own fault that I put the navigationController into a viewController. When I use the navigationController directly, it succeeded. Thank you very much! – wjldxt Jan 03 '12 at 05:59
20
You can do this in storyboard now:
- Select the UIViewController in your storyboard
- Select the checkbox Hide Bottom Bar on Push

Yuchen
- 30,852
- 26
- 164
- 234
5
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;

Zack Zhu
- 378
- 4
- 8
-
not nice, as you assume in this VC that another VC on the stack wants the tabbar - also `viewDidLoad` is the wrong location, as it might be called even when this VC does not yet appear, also `self.tabBarController` might be `nil` – fabb Jun 13 '17 at 12:44
1
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
}

Haroldo Gondim
- 7,725
- 9
- 43
- 62