self.rootViewController = [[RootViewController alloc] initWithNibName:nil bundle:nil];
[self.window addSubview:self.rootViewController.view]; //App will not crash without this line
self.navigationController = [[UINavigationController alloc] initWithRootViewController: self.rootViewController];
[self.window addSubview:self.navigationController.view];
我在模拟器中运行它,它为什么会崩溃?didFinishLaunchingWithOptions方法崩溃
错误消息:
Terminating app due to uncaught exception 'UIViewControllerHierarchyInconsistency',
reason: 'adding a root view controller <RootViewController: 0x6871620> as a child of
view controller:<UINavigationController: 0x6a86dc0>'
仍然不知道
可以显示功能'initWithNibName改变你的贴码:包:'你'RootViewController'? –
,也请添加您的控制台上的错误消息。 –
终止应用程序由于未捕获的异常“UIViewControllerHierarchyInconsistency”,理由是:“增加一个根视图控制器的视图控制器的子:” 仍然不知道 –
JackieLam