Having a Navigation Controller (as the main view) inside a tab bar controller
I've seen a bunch of different tutorials on how this is done. That's fine, I've set up my tab bar controller, have a navigation controller as one of its items, and then set my main view controller as the child of that navigation controller.
If I have an "About" UIBarButtonItem on the main navigation controller's bar, what's the best way of activating the About View Controller? It seems logical that it should开发者_JAVA技巧 be done in the AppDelegate through an IBAction method, but I also kind of feel like it could go in the main view controller some how...
Also, if I'm not initially setting the navigation controller (since I'm setting the tab bar controller as the root), how do I push the about view controller onto its view stack?
Create a UINavigationController
and set your AboutViewController
as your rootViewController
for that navigationView. This way you will be able to set your navigationItem
properties and also push view controllers with the self.navigationController
property.
You need to set your main view controller under UINavigationController
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController: mainViewController];
Then in your main view controller you customize navigationItem property, you can put your UIBarButtonItem here.
self.navigationItem.rightBarButtonItem = your_about_button_here;
精彩评论