3

我的一个应用程序拒绝启动,并且在 iOS7 中遇到了这个异常。excpetion 中的措辞看起来像工程师发脾气,尤其是感叹号。该代码在 iOS 5/6 中运行良好,并且没有与之相关的警告。xcode 5 中也没有警告。包括一个缩写的代码片。我这样做的原因是创建自己的自定义标签栏,它控制应用程序的整个导航。

2013-06-10 22:24:52.862 [3375:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'UINavigationControllers are not allowed in a navigation controller!'

*** First throw call stack:
(0x2c56028 0x29da902 0x1009873 0x2cd22fd 0x2cd2232 0x2c4fae5 0x1009716 0x100943f 0x1008ec5 0x9905 0xef05f9 0xef0daa 0xef21dc 0xf07c6c 0xf081d9 0xef3e55 0x3d6ace2 0x3d6a7ed 0x2bd18d5 0x2bd160a 0x2bfc032 0x2bfb59f 0x2bfb3eb 0xef1960 0xef3b6b 0x8e2d 0x8d95)
libc++abi.dylib: terminating with uncaught exception of type NSException

代码:

UIViewController *homeController, *contactController, *procedureController, *wizardController, *teamController, *askController;

homeController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
UINavigationController *homeNavController = [[UINavigationController alloc] initWithRootViewController:homeController];

wizardController = [[ProcedureWizardController alloc] initWithNibName:@"ProcedureWizardController" bundle:nil];
UINavigationController *wizardNavController = [[UINavigationController alloc] initWithRootViewController:wizardController];

askController = [[AskViewController alloc] initWithNibName:@"AskViewController" bundle:nil];
UINavigationController *askNavController = [[UINavigationController alloc] initWithRootViewController:askController];

teamController = [[TeamViewController alloc] initWithNibName:@"TeamViewController" bundle:nil];
UINavigationController *teamNavController = [[UINavigationController alloc] initWithRootViewController:teamController];

procedureController = [[ProcedureViewController alloc] initWithNibName:@"ProcedureViewController" bundle:nil];
UINavigationController *procNavController = [[UINavigationController alloc] initWithRootViewController:procedureController];


contactController = [[ContactViewController alloc] initWithNibName:@"ContactViewController" bundle:nil];
UINavigationController *contactNavController = [[UINavigationController alloc] initWithRootViewController:contactController];

viewControllers = [NSArray arrayWithObjects:homeNavController, wizardNavController, askNavController, teamNavController, procNavController, contactNavController, nil];

navController = [[UINavigationController alloc] init];;

navController.viewControllers = [NSArray arrayWithArray:viewControllers];
4

1 回答 1

3

例外是正确的。Apple 显然修复了 iOS7 中未在 4,5 和 6 中发现的问题。

不要嵌套 UINavigationControllers。

于 2013-06-11T07:36:08.480 回答