Reputation: 313
I am trying to have the app open on the third tab bar, not the first one. No matter what order I put the apps on the tab bar, the first one to the left always opens first. Can anyone help? Below is the tab bar code.
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
UIViewController *viewController1 = [[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil];
UIViewController *viewController2 = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
UIViewController *viewController3 = [[ThirdViewController alloc] initWithNibName:@"ThirdViewController" bundle:nil];
UIViewController *viewController4 = [[FourthViewController alloc] initWithNibName:@"FourthViewController" bundle:nil];
UITableViewController *viewController5 = [[FifthViewController alloc] initWithNibName:@"FifthViewController" bundle:nil];
self.tabBarController = [[UITabBarController alloc] init];
self.tabBarController.viewControllers = [NSArray arrayWithObjects:viewController3, viewController4, viewController1, viewController2, nil];
self.window.rootViewController = self.tabBarController;
Upvotes: 1
Views: 2267
Reputation: 5966
Just add [self.tabBarController setSelectedIndex:2];
2, because array starts from 0;
Upvotes: 2