uiviewcontroller - 一个 View 一次最多只能与一个 View Controller 相关联。 UIViewController 层次结构不一致

标签 uiviewcontroller ios6

我在 iOs6 上遇到这个问题,在 iOs5 上工作正常。

这会加载登录 View

- (void)viewDidLoad {
if(!currentView ){
      currentView = [[Login alloc] init];
}
self.view = currentView.view;
   [super viewDidLoad]; 
}

这是在 AppDelegate 上

 if (!mvc) {
    mvc = [[[mainViewController alloc] init] autorelease];
}
[window addSubview:mvc.view];
[window sendSubviewToBack:mvc.view];
[window makeKeyAndVisible];

2013-01-15 18:02:33.137 fodboldfabrikken[5412:19d03] * 由于未捕获的异常“UIViewControllerHierarchyInconsistency”而终止应用程序,原因:“一个 View 最多只能与一个 View Controller 关联时间!查看 > 与 关联。在将此 View 与关联之前清除此关联。' * 首先抛出调用栈: (0x2097012 0x1c78e7e 0x2096deb 0xa90309 0xb275ac 0xb23a90 0x3206 0xb23817 0xb23882 0x2b49 0xa3f7b7 0xa3fda7 0xa40fab 0xa52315 0xa5324b 0xa44cf8 0x2aafdf9 0x2aafad0 0x200cbf5 0x200c962 0x203dbb6 0x203cf44 0x203ce1b 0xa407da 0xa4265c 0x2a4d 0x2985 0x1) libc++abi.dylib:终止调用抛出异常

最佳答案

你不允许在另一个 Controller 中有一个 Controller ,这是你在这里做的 mvc = [[[mainViewController alloc] init] autorelease];

关于uiviewcontroller - 一个 View 一次最多只能与一个 View Controller 相关联。 UIViewController 层次结构不一致,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14341985/

相关文章:

objective-c - 如何获取 Root View Controller ?

ios - 以编程方式创建 UINavigationController 并将 UICollectionViewController 嵌入到容器中

iphone - UINavigationController setViewController :animated: navigation bar difficulties

iphone - IO6 不调用 -(BOOL)shouldAutorotate

ios - 限制广告跟踪和广告 sdk

ios - 不阻止访问父级的模态视图

iphone - 在uiviewcontroller View 中绘制横线和竖线

ios - BadgeValue不能在UITabBarItem上更新

iphone - iOS - 如何使用应用程序联系人有选择地导入/导出 iPad 联系人

ios - 从方形 AVCaptureVideoPreviewLayer 获取图片