I am following Stanford’s iPhone Development course in iTunes U and I’m having problem with one of their assignments (Paparazzi, if anyone is familiar).
What I’m trying to do is basically to create this view as the first ‘screen’ upon application launch:
And this is the code that I have in the app delegate:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// PersonListViewController is the 'content' of the screen (image, name, and button)
PersonListViewController* personList = [[PersonListViewController alloc] initWithNibName:@"PersonListViewController" bundle:[NSBundle mainBundle]];
navController = [[UINavigationController alloc] initWithRootViewController:personList];
[personList release];
UITabBarController* tabBarController = [[UITabBarController alloc] init];
[window addSubview:[tabBarController view]];
[window addSubview:[navController view]];
[window makeKeyAndVisible];
return YES;
}
But this code doesn’t seem to show the tabBar on the bottom, only the navigation bar and the view in the middle (image, name, and the button).
Can someone explain to me what I did wrong and how to fix it?
What you typically do is nest your main ViewController (in this case,
PersonListViewController) inside aUINavigationController(like you have done), but then you set thetabBarController.viewControllersproperty equal to an array of view controllers (one for each tab).In your case, that would look like
Then add only the tabBarController’s view to the window
This will give you your list, inside a nav controller, inside a tab controller (and the tab controller will only have one tab, for now).