I’m working through the fairly typical process of building view controllers and their associated navigation controllers programmatically, and then adding the navigation controllers to a tabBarController.
self.tabBarController = [[[UITabBarController alloc] init] autorelease];
[self.tabBarController setHidesBottomBarWhenPushed: YES];
FirstViewController * firstView = [[[FirstViewController alloc] init] autorelease];
firstView.title = @"First";
firstView.tabBarItem.image = [UIImage imageNamed:@"icon_first_view.png"];
UINavigationController * firstViewNav = [[[UINavigationController alloc] initWithRootViewController:firstView] autorelease];
[tabBarController setViewControllers:[NSArray arrayWithObjects: firstViewNav, nil]];
That works fine, and the NavigationController title and the TabBar title will say “First”. Now, I would like to change the Navigation Controller title to say “FooBar”, and leave the tab bar title as “First”.
I’ve tried:
firstViewNav.navigationItem.title = @"FooBar";
But that doesn’t seem to change it. If I change the title on the actual ViewController managed by this nav controller (firstView.title), then both the TabBar title and the Navbar title both change, which is not desired.
Any ideas?
just hide the NavigationBar and add a toolbar with the title you want.