Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hide/disable only the first uinavigationbar?

I've been wandering how to hide / remove / disable only the main or first navigation bar in the navigation controller so that I could put an image as a whole background screen but I couldn't find any solution.

Did try hide the titleview in viewdidLoad of the main navigation controller but didn't work. Tried using navigationBarHidden but it hides the whole navigation bar for the next stack of controller.

So, I'm not sure how to do this. To give you an example, I would like to have something like this app - The Masters Golf Tournament - http://appshopper.com/sports/the-masters-golf-tournament.

If you look at Screen 1, it doesn't have any nav bar at the top but when you touch any options it will push to a new view controller and have the nav bar appear as in Screen 3,4 and 5.

Hope anyone could help me with this.Thanks a lot!

like image 210
Jack B. Avatar asked Jul 31 '10 04:07

Jack B.


3 Answers

In most of my applications I have a custom UIViewController class that I derive all other custom controllers from. In some of these, I added a method like navigationBarInitiallyHidden to the base class that other classes can override. The default result depends on the nature of the application.

In the delegate of the navigation controller, when a controller is being shown that implements that method, the delegate hides or shows the navigation controller accordingly. Since I animate the hide or show, I check the current state and do nothing if no change is needed.

You could do something simpler in your delegate method. If the controller being shown is the root controller, hide the navigation bar, otherwise show it if it is hidden.

- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
  if ( viewController == rootController ) {
    [navigationController setNavigationBarHidden:YES animated:animated];
  } else if ( [navigationController isNavigationBarHidden] ) {
    [navigationController setNavigationBarHidden:NO animated:animated];
  }
}
like image 59
drawnonward Avatar answered Nov 12 '22 20:11

drawnonward


You can hide the navigation bar: [self.navigationController setNavigationBarHidden:YES]; and where you want to show the navigation bar again [self.navigationController setNavigationBarHidden:NO];

like image 45
yasha02 Avatar answered Nov 12 '22 21:11

yasha02


hide/disable

self.navigationController.navigationBarHidden = YES;

show/Enable

self.navigationController.navigationBarHidden = NO;
like image 23
ArNo Avatar answered Nov 12 '22 22:11

ArNo