开发者

How do I set the title of a UINavigationBar?

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"] in viewDidLoad, 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜