Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hiding the UINavigationBar only for the root UIViewController

I am using a UINavigationController (side note: inside a UITabBar) which by default gives you a UINavigationBar on the top. If I hide the bar through IB, the bar is gone not only for the root UIViewController but also for all the controllers I push onto the stack. Leaving me no (automatic) way to pop back.

So how can hide the UINavigtionBar only on the root UIViewController. Switching on/off "navigationBarHidden" temporarily does not work as this looks awkward with the animation.

Any other ideas?

like image 455
tcurdt Avatar asked Aug 19 '09 10:08

tcurdt


1 Answers

For me the easiest way to avoid the white space after hided the UInavigationBar is to hide or show your UInaviagtionBar as follow.

 -(void)viewWillDisappear:(BOOL)animated
{
    [super viewDidDisappear:animated];
    [self.navigationController setNavigationBarHidden:NO animated:YES];
}
-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:YES animated:YES];
}

with the syntax : self.navigationController.navigationBarHidden = YES; i always have the white space.

like image 188
Amnysia Avatar answered Sep 29 '22 12:09

Amnysia