以下是在我的 AppDelegate 中:
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
customViewController = [[CustomViewController alloc] initWithNibName:@"CustomViewController" bundle:nil];
self.navigationController = [[UINavigationController alloc] initWithRootViewController:customViewController];
[self.navigationController setNavigationBarHidden:YES];
self.window.rootViewController = self.navigationController;
[self.window makeKeyAndVisible];
在实际的 XIB 中, View 与“文件的所有者”关联,这是我在那里的唯一关联..
XIB 层次结构:
Navigation Controller
- View Controller - Root View Controller
-View (Associated with File's Owner)
抱歉,如果我不明白这一点,它在之前启动的应用程序上运行良好,但我明白这并不意味着它是正确的。
编辑:抱歉,这是我收到的错误:
* 由于未捕获的异常“UIViewControllerHierarchyInconsistency”而终止应用程序,原因:“一个 View 一次最多只能与一个 View Controller 相关联!查看 < UIView: 0xa192d00;帧 = (0 20; 320 460);自动调整大小 = W+H;层 = < CALayer: 0xa192d60>> 与 < UIViewController: 0xa195c70> 关联。在将此 View 与
最佳答案
确保您的 View 界面在其层次结构中没有额外的 View Controller 。请参阅下面的屏幕截图
之前:
之后:
关于iphone - iOS 6 : What changed that made this View Controller Hierarchy break?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12606847/