I create window based app (call it TabBar). In TabBarAppDelegate I create two UIViewControllers and one UITabBarController.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. UIViewController *vc1 = [[UIViewController alloc] initWithNibName:@"MyFirstViewController" bundle:nil]; UIViewController *vc2 = [[UIViewController alloc] initWithNibName:@"MySecondViewController" bundle:nil]; NSArray *contr = [NSArray arrayWithObjects:vc1, vc2, nil]; UITabBarController *tbc = [[UITabBarController alloc] init]; tbc.viewControllers = contr; [self.window addSubview:tbc.view]; [self.window makeKeyAndVisible]; [vc1 release]; [vc2 release]; return YES; }
In MyFirstViewController.xib I create uilabel (using IB for test that view is loaded) and for MySecondViewController.xib too.
And app build and run successful, but uitabbaritem - without image and title. I tried to add in MyFirstViewController.m this lines for set title and image of MyFirstViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { UITabBarItem *item = [[UITabBarItem alloc] initWithTitle:@"first" image:[UIImage imageNamed:@"first.png"] tag:0]; self.tabBarItem = item; [item release]; } return self; }
But first tabbaritem isn't change. Help me please. I don't understand what I'm doing wrong.