I am creating app based on UTabbarController. I have creates that tab bar programmatically. Everything is running fine except I can not see the tabBatItem title. I have initialized everything properly, but when application launches all I can see is the first tabbar title. but if I select 2nd tabbaritem or so on I can see their names. I don’t know whats going wrong here. Here is my code. Please let me know if I made any mistake.
Thanks.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
HomeViewController *viewController1 = [[HomeViewController alloc] initWithNibName:@"HomeViewController" bundle:nil];
UINavigationController*navController1=[[UINavigationController alloc]initWithRootViewController:viewController1];
navController1.title=@"Home";
[viewController1 release];
TrainerTableViewController *viewController2 = [[TrainerTableViewController alloc] initWithNibName:@"TrainerTableViewController" bundle:nil];
UINavigationController*navController2=[[UINavigationController alloc]initWithRootViewController:viewController2];
navController1.title=@"Trainer";
[viewController2 release];
SettingsTableViewController *viewController8 = [[[SettingsTableViewController alloc] initWithNibName:@"SettingsTableViewController" bundle:nil] autorelease];
UINavigationController*navController8=[[[UINavigationController alloc]initWithRootViewController:viewController8]autorelease];
navController1.title=@"Settings";
AboutUsViewController *viewController9 = [[[AboutUsViewController alloc] initWithNibName:@"AboutUsViewController" bundle:nil] autorelease];
UINavigationController*navController9=[[[UINavigationController alloc]initWithRootViewController:viewController9]autorelease];
navController1.title=@"About Us";
self.tabBarController = [[[UITabBarController alloc] init] autorelease];
self.tabBarController.viewControllers = [NSArray arrayWithObjects:navController1, navController2,navController8, navController9, nil];
[navController1 release];
[navController2 release];
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];
return YES;
}
You can do this by including the code below inside the .m file of the view controller for each tab bar item. The code also includes how to change the image on the tab bar.