UIViewControllerHierarchyInconsistency在ios​​5中工作,但在ios6中不工作

前端之家收集整理的这篇文章主要介绍了UIViewControllerHierarchyInconsistency在ios​​5中工作,但在ios6中不工作前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个完美的工作项目,直到我更新到ios6.

当我在一个条形项上选项卡显示一个带有视图的弹出窗口时应用程序崩溃…

这是我得到的错误

"reason: 'A view can only be associated with at most one view controller at a time! View <UIView: 0xaa7d730; frame = (20 0; 748 1024); autoresize = RM+BM; layer = <CALayer: 0xaa7d790>> is associated with <TYOFormViewController: 0xaa7d8b0>. Clear this association before associating this view with <TYOFormViewController: 0x14c68a70>.'"

这是声明UIViewController和UIPopoverController的方法.

- (IBAction)TestDriveTapped:(id)sender{
if (PopoverController != nil) {
    [PopoverController dismissPopoverAnimated:YES];
    self.PopoverController = nil;
}
if (self.PopoverController == nil) {
    UIViewController *bookTestDrive =[[TYOFormViewController alloc] initWithNibName:@"TYOBookTestDriveForm" bundle:nil];

   UIPopoverController *poc  = [[UIPopoverController alloc]
                           initWithContentViewController:bookTestDrive];

   [poc presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
     self.PopoverController = poc;
} else {
    if (PopoverController != nil) {
        [PopoverController dismissPopoverAnimated:YES];
        self.PopoverController = nil;
    }
}

}

错误说我必须清除与TYOFormViewController的关联,以将它与TYOFormViewController关联….这是怎么发生的?

非常喜欢你对这个问题的帮助… jstuck整天都在用它…

谢谢

解决方法

加载一堆xib文件时,我也发生了这种情况.解决方案是进入界面构建器并删除文件所有者具有相同类名的任何视图控制器对象.所以在我的情况下,这些文件现在只包含视图和子视图,连接到文件的所有者 – 没有控制器.

在解释xib文件时,iOS 6中的某些内容必定会发生变化.

猜你在找的iOS相关文章