rottendevice rottendevice - 5 months ago 128
Objective-C Question

hidesBottomBarWhenPushed = NO not working?

I have a

UITabBar
in my app, which I'm hiding on the first
UIViewController
in the first tab by putting this line in the AppDelegate:

// ... in MyAppDelegate.m
firstViewController.hidesBottomBarWhenPushed = YES;


In the
firstViewController
, the user can push a
UIButton
that pushes a new
UIViewController
in the same tab. I'd like for the
UITabBar
to be visible again when this happens. I'm trying to make it come back like this:

//... in firstViewController.m

secondViewController = [[SecondViewController alloc] init];
secondViewController.hidesBottomBarWhenPushed = NO;
[[self navigationController] pushViewController:secondViewController animated:YES];


Unfortunately, does not bring back the
UITabBar
. It remains hidden.

How do I properly bring bar the
UITabBar
after hiding it?

Thanks in advance.

Answer

This is what the documentation for hidesBottomBarWhenPushed says (emphasis added):

If YES, the bottom bar remains hidden until the view controller is popped from the stack.

So it looks like the behavior your're seeing is just what the documentation says will happen. You start by pushing a view controller onto the stack which has hidesBottomBarWhenPushed = YES. At that point, pushing other view controllers onto the stack won't change the hiddenness of the bottom bar. As long as that first view controller is on the stack, the bottom bar will remain hidden.

So I think you'll have to come up with a different way of accomplishing your UI goal. One option would be to present the first view controller as a modal view controller over the tab bar controller's view. Then, when you want to go to the second view controller just dismiss the first one and viola. The only visual difference will be the transition animation.

There are surely other options too, but that just came first to my mind.

Good luck!