Setting title of UINavigationBar

*爱你&永不变心* 提交于 2019-12-01 03:08:12

问题


I have an application which uses a main story board to include a Navigation Controller where the main view is a Table View using a prototype cell content. Each cell in the table view pushes onto a new view which I have created with it's own set of .h .m and .xib files.

The table view navigation bar has its title set through the story board which works fine. However, I am having trouble setting the title for each new view after it gets pushed into view.

I have the following in the viewDidLoad method for each view;

self.title = @"View Title";

Any advice?


回答1:


it is the right way. it will work.




回答2:


I'm doing something similar in an app I'm working on. Here's how I'm setting the title:

[[self navigationItem] setTitle:@"My View's Title"];

I thinkt the dot notation equivalent would be something like this:

self.navigationItem.title = @"My View's Title";

Hope that helps.




回答3:


If you have a tab bar controller, try this:

self.tabBarController.navigationItem.title = @"Title";


来源:https://stackoverflow.com/questions/8519512/setting-title-of-uinavigationbar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!