Reputation: 7606
the issue is that I have created a UINavigationBar in interface builder and I want to change the title. The Navigation bar is not hooked up to my UINavigation controller. Is there any way I can accomplish this with the Navigation Bar as a stand alone from my Nib?
The second part of my question is more a general understanding of how the UINavigationBars work. I don't understand how the stack of navigation items works. for example what if i want to change the right button item to say "done" instead of "edit"? My understanding is that the left, center, and right bar button item are on a stack? but then how do I know which item is at what place in the stack. I'm sorry if I am missing something elementary here but I need some clarification on how the left, center and right bar button items are managed, and how the stack works into this. Thanks in advance.
Upvotes: 1
Views: 1590
Reputation: 500
create un IBOutlet of this UINavigationBar that you created in interface builder
@property (weak, nonatomic) IBOutlet UINavigationBar *navigationBar;
then change title with
self.navigationBar.topItem.title = @"My Custom Title";
Upvotes: 1
Reputation: 61
UINavigationController is a subclass of UIViewController, but unlike UIViewController it’s not usually meant for you to subclass. This is because navigation controller itself is rarely customized beyond the visuals of the nav bar.
An instance of UINavigationController can be created either in code or in an XIB file with relative ease. It’s thought of as a stack: it has a root view controller, and then new view controllers can be pushed onto the stack (often when the user taps on a row in a table) or popped off the stack (often by pressing the back button).
The root view controller can be set in an XIB by dragging the view controller under the navigation controller, or in code by using initWithRootViewController when you create it.
The Navigation Stack
Four methods are used to navigate user through the stack:
– pushViewController:animated: – popViewControllerAnimated: – popToRootViewControllerAnimated: – popToViewController:animated:
Upvotes: 1
Reputation: 96927
You could use a custom titleView
in the navigation bar, in which you have added a UILabel
with the text of your choice.
Read the "Configuring the Navigation Item Object" section of Apple's View Controller Programming Guide for iPhone OS documentation for more information on how to customize the navigation bar.
Upvotes: 3