I want to add some stuff to the navigation bar (like Heading and some buttons like back or home, a shopping cart and a Youtube EN开发者_运维百科DO channel) at the top of the view. But navigation bar is not visible in the nib file. That can be done through some coding stuff. So, how can I add them to navigation bar?? Please help
regards Prateek
You need to add your view controller to a UINavigationController
first. There are two scenarios:
Either, from your root controller. Just look at the template "Navigation based Application" in Xcode / New Project for how to do this. Most things just happen automatically. When you push a view controller, it should already have a navigation bar. Also, you will find it in your xib file.
Or, from another view controller that is not part of a navigation controller. Before pushing it, "wrap" it into a navigation controller like this:
MyViewController *controller = [[MyViewController alloc] init];
UINavigationController *nav = [[UINavigationController alloc]
initWithRootViewController:controller];
[self presentModalViewController:nav animated:YES];
[controller release];
[nav release];
Now you can add to self.navigationController.navigationBar
to your heart's content.
精彩评论