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.
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.
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.
In case you're using tabbar with navigation controller hidesBottomBarWhenPushed will not work, but tabBarController. tabBar. hidden will do.
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With