Hi, I'm completely new and I'm simply trying to make an iPhone app with two tabs on the bottom (for learning purposes), one for each of my two custom views. I created an Xcode "view-based-application" project and then created two subclasses of UIViewController (for my two custom views). I then went to the associated xib files for each UIViewController subclass (which I named MyVC1 and MyVC2) and put a label in each one with different text so I could tell if it worked or not. I then put the following code into my projectAppDelegate.m class:
Code:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
MyVC1 *vc1 = [[MyVC1 alloc] init];
MyVC2 *vc2 = [[MyVC1 alloc] init];
UITabBarController *tbc = [[UITabBarController alloc] init];
tbc.viewControllers = [NSArray arrayWithObjects: vc1, vc2, nil];
[vc1 release];
[vc2 release];
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
[self.window addSubview:tbc.view];
[self.window makeKeyWindow];
return YES;
}
These are the only changes I made. When I run this, the simulator shows the two tabs at the bottom, but when I click them, the labels in MyVC1 and MyVC2 don't show up (it's just white). Can someone please walk me through what I have to do to get this simple app working? Do I need to change my code? Do I need to make some associations somewhere in InterfaceBuilder with my MyVC1.xib and MyVC2.xib? Any help would be appreciated.
EDIT: I just realized why the label wasn't showing up. I alloced MyVC1 twice instead of MyVC2 the second time and MyVC2 was the only one I put a label in. Sorry for the dumb mistake. But I still feel like I'm not quite getting something or that I'm doing something wrong. Can someone tell me what they would've done differently to achieve what I was trying to achieve? Thanks.