开发者

iPhone SDK have a different title on the tab bar and the navigation bar

I have a simple question (maybe not a simple answer). Currently I have an iPhone app and I tab bar and navigation set up on it. When I set the self.title it puts it in both the tab开发者_运维知识库 bar and the navigation bar. I was wondering if there was a way to have a different title on the navigation bar and tab bar?


You're setting the title of the whole view, which in turn automatically sets the title of the tabBar and the nav controller. To set the title of them each individually, You first set the nav bar by accessing the nav item:

[[self navigationItem] setTitle:(NSString *)];

Then you set the tabBar title by accessing the tab bar item and setting its title like so:

[self.tabBarItem setTitle:(NSString *)];

Good Luck!


use self.navigationItem.title for the navigation bar.


This is a common mistake and happened to me so many times.

To get around this, every ViewController comes with a navigationItem property giving you even further options.

Use following line inside your ViewControllers to set the title:

self.navigationItem.title = @"Your Desired Title";
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜