Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hide UITabBar?

In my app I have a tab bar. And in some views I as well have a toolbar. So when I come to those views with a toolbar it looks ugly - two bars at the bottom of the view. I thought that it would be a best solution to hide a tab bar when entering those particular views. But I just couldn't figure out how to do it in a right way. I tried to set UITabBarController's tabBar hidden property to YES, but it didn't work. And I as well tried to do the following thing in whatever view I am:

self.hidesBottomBarWhenPushed = YES; 

But it didn't work as well.

What is the right solution to this situation? I don't want to have 2 bars at any view.

like image 918
Ilya Suzdalnitski Avatar asked May 02 '09 21:05

Ilya Suzdalnitski


People also ask

How do I hide the tab bar?

If using Storyboards you can simply uncheck a checkbox in your ViewController's Attribute Inspector. It's called "Hide Bottom Bar on Push". Very convenient indeed, and no need to handle the showing of the tabBar again after navigating back from your tabBar-less viewController.

How do I hide the tab bar in Swift?

If you don't want that behavior, you should set hidesBottomBarWhenPushed to true where applicable. This will hide the tab bar along with any toolbars you had showing, but only when a view controller is pushed onto the navigation stack. This allows you to show the tab bar at first, then hide it when you need more room.

How do I hide the tab bar in Objective C?

In case you're using tabbar with navigation controller hidesBottomBarWhenPushed will not work, but tabBarController. tabBar. hidden will do.

How do I hide the bottom bar in Swift?

Answer: Use self. tabBarController?. tabBar. hidden instead of hidesBottomBarWhenPushed in each view controller to manage whether the view controller should show a tab bar or not.


2 Answers

You have to use set the hidesBottomBarWhenPushed property to YES on the controller that you are pushing and NOT to the UITabBarController.

otherController.hidesBottomBarWhenPushed = YES; [navigationController pushViewController: otherController animated: TRUE]; 

Or you can set the property when you first initialize the controller you want to push.

like image 54
Panagiotis Korros Avatar answered Sep 20 '22 17:09

Panagiotis Korros


Interface builder has checkbox for view controller embedded in tab bar - Hides bottom bar on push. In easy cases no need to do it through code now.

For @Micah

Hide bottom bar on push.

like image 26
Vladimir Shutyuk Avatar answered Sep 23 '22 17:09

Vladimir Shutyuk