如果您使用情节提要,那么应该有起点。所以以情节提要中的 uitabarcontroller 为起点,并将引用链接到 tabBarController
NSMutableArray *listOfViewControllers = [[NSMutableArray alloc] init];
UIViewController *vc;
vc = [[UIViewController alloc] init];
vc.title = @"A";
[listOfViewControllers addObject:vc];
[vc release];
vc = [[UIViewController alloc] init];
vc.title = @"B";
[listOfViewControllers addObject:vc];
[vc release];
vc = [[UIViewController alloc] init];
vc.title = @"C";
[listOfViewControllers addObject:vc];
[vc release];
[self.tabBarController setViewControllers:listOfViewControllers
animated:YES];
}
没有情节提要,也没有在 XIB 中使用 UITabbarController
UITabBarController *tabBarController = [[UITabBarController alloc] init];
NSMutableArray *listOfViewControllers = [[NSMutableArray alloc] init]; UIViewController *vc;
vc = [[UIViewController alloc] init];
vc.title = @"A";
[listOfViewControllers addObject:vc];
[vc release];
vc = [[UIViewController alloc] init];
vc.title = @"B";
[listOfViewControllers addObject:vc];
[vc release];
vc = [[UIViewController alloc] init];
vc.title = @"C";
[listOfViewControllers addObject:vc];
[vc release];
[tabBarController setViewControllers:listOfViewControllers
animated:YES];