I have 3 tabs and main navigation controller. I implements with code:
UIViewController *monitorController = [[[MonitorController alloc] initWithNibName:@"MonitorController" bundle:nil] autorelease];
UIViewController *dashboardController = [[[DashboardController alloc] initWithNibName:@"DashboardController" bundle:nil] autorelease];
UIViewController *settingsController = [[[SettingsController alloc] initWithNibName:@"SettingsController" bundle:nil] autorelease];
self.tabBarController = [[[UITabBarController alloc] init] autorelease];
self.tabBarController.viewControllers = [NSArray arrayWithObjects:monitorController, dashboardController, settingsController, nil];
self.navigationController = [[[UINavigationController alloc] initWithRootViewController:self.tabBarController] autorelease];
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.rootViewController = self.navigationController;
[self.window makeKeyAndVisible];
I want to change navigation title when I select another tap, but no variant (see below) not working (there are no any title at navigation controller):
self.title = DASHBOARD_TITLE;
self.navigationController.title = DASHBOARD_TITLE;
How I can resolve this problem?
The
UINavigationControllerwill display the title of theUIViewControllerit’s currently displaying, that is why you are not able to set it directly.You may try to change the
titleon yourUITabBarController, but I’m not sure the navigation controller will update it’s title after it first appeared on screen.But, Do you really need that Architecture?
Usually the
UITabBarControlleris theroot viewControllerand if you needUINavigationControllersthey are placeinsidethe Tab that need to have navigation capability.It was design to be use that way.
Quoted from UITabBarController Class Reference