问题
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