开发者

How do I set the title of a UINavigationBar?

开发者 https://www.devze.com 2023-03-18 07:32 出处:网络
This is what I did so far: I created a new view based iPhone application I added a navigation bar to the xib file

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

精彩评论

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