Show UITabBar when UIViewController pushed

kombucha picture kombucha · Feb 22, 2011 · Viewed 11.2k times · Source

Here's my situation :
I have a UINavigationController inside a UITabBarController. When I drill down the navigation controller, at some point I have to hide the UITabBar because I want the view to have as much space as possible.
I do that by using self.hidesBottomBarWhenPushed = YES inside the pushed UIViewController, and it works quite well.
However, I want to show the UITabBar back in the following pushed controllers. I've tried to put self.hidesBottomBarWhenPushed = NO in the other controllers, but the UITabBar won't come back.

It seems to be normal as the documentation states :

hidesBottomBarWhenPushed

If YES, the bar at the bottom of the screen is hidden; otherwise, NO. If YES, the bottom bar remains hidden until the view controller is popped from the stack.

And indeed, when the controller with this property set to yes is popped, the tabbar does come back.

Is there any proper way to show the UITabBar when a controller is pushed, once it's been hidden?

Thanks in advance

Answer

AmitP picture AmitP · Jul 15, 2012

hidesBottomBarWhenPushed is not deprecated. I found it is very simple to achieve the hide and show UITabBar using the following method:

self.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:detailViewController animated:YES];
[detailViewController release];
self.hidesBottomBarWhenPushed = NO;

So right after you push the detailViewConroller, you should reset the hide property back to NO. This way it will show up again when the detail view pops back. no need for any additional changes in viewWillApear/ disapear,etc.. Enjoy.