Strong Like Bull
Strong Like Bull

Reputation: 11317

How to add a UITableViewController to a UINavigationController that is on a UITabViewController in XCode4?

I was following this tutorial on http://www.youtube.com/watch?v=LBnPfAtswgw and was able to replicate that in XCode 3 however with XCode 4 I am having some issues.

My app's root view controller is a UITabBarController on which I selected one of the tabs and selected a UINavigationController and then dragged a view as the tutorial suggests but am unable to select my UITableViewController class?

I also do not see a section where it says to select a tab bar controller and select the UINavigation controller (around 9:08)

Can anyone guide me as to what I am doing wrong?

Upvotes: 0

Views: 858

Answers (1)

Rick
Rick

Reputation: 1215

You can do the same by using the following code:

    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
TablelViewController *viewController1 = [[TablelViewController alloc] initWithNibName:@"TablelViewController" bundle:nil];
UINavigationController *navigationController1 = [[UINavigationController alloc] initWithRootViewController:viewController1];

TableViewController2 *viewController2 = [[TableViewController2 alloc] initWithNibName:@"TableViewController2" bundle:nil];
UINavigationController *navigationController2 = [[UINavigationController alloc] initWithRootViewController:viewController2];

self.tabBarController = [[UITabBarController alloc] init];
self.tabBarController.viewControllers = [NSArray arrayWithObjects:navigationController1, navigationController2, nil];

self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];

This code goes in: - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

Upvotes: 1

Related Questions