Reputation: 15
I've used [[self navigationController] setTitle:@"Test Title"] to no avail. This is the same way I do it in the rest of my app. What could cause this?
Upvotes: 1
Views: 4141
Reputation: 31
SecondViewController *s1=[[SecondViewController alloc]initWithNibName:@"SecondViewController" bundle:nil];
[s1 setTitle:@"Second Page"];
[self pushViewController:s1 animated:YES];
Worked for me.
Upvotes: 1
Reputation: 11
CustomViewController *viewController = [[CustomViewController alloc] init];
[viewController setTitle:@"CustomViewController!";
[custonNavigationController pushViewController:viewController animated:YES];
This is a simplification of what Daniel had said. This method properly follows stack protocol.
Upvotes: 1
Reputation: 22405
You are using the title property incorrectly, the navigationController has a title property because it inherets from UIViewController, the title property is used by NavigationControllers to display a title, so if you wanted the title you gave your NavigationController to show you would need to present it in another NavigationCOntroller...But what you need to do, is set the viewControllers that you are displaying titles instead of the NavigationController, now whenever u display that VC youll see the title in the navigation bar... In short...the viewcontrollers title property is used by its navigationController to display the title on the navigation bar when that viewcontroller is on the top of the navigation stack...
Upvotes: 1
Reputation: 15238
Try setting the title of the navigation item.
self.navigationItem.title = @"Test Title";
Or like this if you prefer
[[self navigationItem] setTitle:@"Test Title"];
Upvotes: 4