This is what I did so far:
- I created a new view based iPhone application
- I added a navigation bar to the xib file
How do I set the title of this navigation bar?
- If I try
[self setTitle:@"Test"]
inviewDidLoad
, the title of the navigation bar doesn't change, but rather it remains "Title". - If I try
[[self navigationItem] setTitle:@"Test"]
, the title becomes empty.
How can I change this title?
If the view was pushed onto the navigation stack, then
[[self navigationItem] setTitle:@"Test"];
should exactly work. However, since you created the bar in the xib file, try making an IBOutlet
for it, and then access the title
property through the pointer.
精彩评论