As this question [kind of] asks, how can I setup some toolbar items in my MainWindow.xib and have those items present when I use the UINavigationController pushViewController:animated:.
For example, my application has:
MainWindow.xib, which contains aUINavigationControllerwith navigation bar and a toolbar.AViewController.xib, which just contains aUITableView.
At some point, our user presses a toolbar button and the associated action performs:
- (void)someAction {
[self.navigationController pushViewController:[[AViewController alloc]
initWithNibName:nil bundle:nil]
animated:YES];
}
When the new view gets pushed, it contains a blank toolbar, instead of the toolbar with the same items as before. What’s the preferred method for keeping them the same? I feel like I’m just missing something simple! Thanks in advance!
I would have one of my classes adopt the
UINavigationControllerDelegateprotocol and implement thenavigationController:willShowViewController:animated:method like this,where I create and store
toolbarItemsin the delegate class. One of the likely candidates for being the delegate is the application delegate class as it is most probable place where you will instantiate the navigation controller.