Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

kingthong

macrumors member
Original poster
Sep 20, 2010
62
0
Somewhere but not here.
This is a rather unusual problem and i'm sure there is a simple fix for it.

I read the Apple Docs on View Controllers and combining View Controllers. So i copy pasted the code available for using a Tabbar and a Navigation Controller together, into Xcode.

Here's the code:

Code:
- (void)applicationDidFinishLaunching:(UIApplication *)application {

   tabBarController = [[[UITabBarController alloc] init] autorelease];

   MyViewController1* vc1 = [[[MyViewController1 alloc] init] autorelease];

   MyViewController2* vc2 = [[[MyViewController2 alloc] init] autorelease];

   MyViewController3* vc3 = [[[MyViewController3 alloc] init] autorelease];

   MyNavRootViewController* vc4 = [[[MyNavRootViewController alloc] init] autorelease];

   UINavigationController* navController = [[[UINavigationController alloc]

                           initWithRootViewController:vc4] autorelease];

   NSArray* controllers = [NSArray arrayWithObjects:vc1, vc2, vc3, navController, nil];

   tabBarController.viewControllers = controllers;

   // Add the tab bar controller's current view as a subview of the window

   window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];

   [window addSubview:tabBarController.view];

}

The program opens fine, but the name for each tabbar button appears only after it's clicked. The reason is because i've specified the self.title in the viewDidLoad. i tried specifying it in the LoadView and the awakeFromNib functions as well, but the problem persisted .

Any suggestions?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.