Press the button and load the navigation controller

A very simple question: my iPhone application has a button in MainWindow.xib. When I click this button, the new mode should load. This view will contain a good navigation controller. How can i do this?

All the information that I found relates to applications that run directly from the navigation controller. I need to load the nav controller after clicking a button.

Thank you very much!

+4
source share
1 answer

Another way to do this is to simply hide the navigation bar in the root controller:

- (void) viewDidLoad { ... if (![self.navigationController isNavigationBarHidden]) [self.navigationController setNavigationBarHidden:YES animated:NO]; ... } 

This way you have a clean, clean root controller without a navigation bar.

When you press the button in the root controller, you simply enter a new view and hide the navigation bar:

 - (IBAction) pushAnotherView:(id)sender { AnotherViewController *anotherViewController = [[AnotherViewController alloc] initWithNibName:@"AnotherViewController" bundle:nil]; [self.navigationController pushViewController:anotherViewController animated:YES]; if ([self.navigationController isNavigationBarHidden]) [self.navigationController setNavigationBarHidden:NO animated:YES]; [anotherViewController release]; } 

If you have a notification or other action that returns you to the root view controller, just hide the notification panel again:

 - (void) viewWillAppear:(BOOL)animated { if (![self.navigationController isNavigationBarHidden]) [self.navigationController setNavigationBarHidden:YES animated:YES]; [super viewWillAppear:animated]; } 
+2
source

All Articles