1

我试图在第三个标签栏上打开应用程序,而不是第一个。无论我将应用程序放在标签栏上的顺序如何,左侧的第一个总是首先打开。任何人都可以帮忙吗?下面是标签条码。

 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;
4

2 回答 2

6

你试过了吗

[self.tabBarController setSelectedIndex:2];
于 2012-04-12T23:12:46.273 回答
2

只需添加[self.tabBarController setSelectedIndex:2];

2、因为数组从0开始;

于 2012-04-12T23:13:51.233 回答