刚刚创建了一个新项目,我添加了 4 个视图控制器,UINavigationController
如下所示:
WatchViewController *first = [[WatchViewController alloc] init];
BetViewController *second = [[BetViewController alloc] init];
Settings *third = [[Settings alloc] init];
Account *forth = [[Account alloc] init];
UINavigationController *navFirst = [[UINavigationController alloc]initWithRootViewController:first];
UINavigationController *navSecond = [[UINavigationController alloc]initWithRootViewController:second];
UINavigationController *navThird = [[UINavigationController alloc]initWithRootViewController:third];
UINavigationController *navForth = [[UINavigationController alloc]initWithRootViewController:forth];
将它们加载到数组中:
NSArray *viewArray = [[NSArray alloc] initWithObjects:navFirst, navSecond, navThird, navForth, nil];
加载标签栏和窗口:
self.tabController = [[UITabBarController alloc] init];
[self.tabController setViewControllers:viewArray animated:YES];
[self.window setRootViewController:self.tabController];
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
所有视图都只是标准视图。当我尝试运行应用程序时,它会响应:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Pushing a navigation controller is not supported'
我无法弄清楚我错过了什么。有什么帮助吗?