作者热门文章
- objective-c - iOS 5 : Can you override UIAppearance customisations in specific classes?
- iphone - 如何将 CGFontRef 转换为 UIFont?
- ios - 以编程方式关闭标记的信息窗口 google maps iOS
- ios - Xcode 5 - 尝试验证存档时出现 "No application records were found"
我正在尝试构建我的应用程序,有一次我推送了一个 UIViewController,然后我收到了这个错误。我不确定为什么。
'UIViewControllerHierarchyInconsistency', reason: 'A view can only be associated with at most one view controller at a time! View > is associated with . Clear this association before associating this view with .'
PageViewController *viewController;
viewController = [[PageViewController alloc] initWithManagedObjectContext:managedObjectContext];
dataSource = [[PagesDataSource alloc] initWithManagedObjectContext:managedObjectContext];
PVPage *selectedPage = [[dataSource pages] objectAtIndex:itemIndex];
[viewController setRepresentedPage:selectedPage];
PageFlipperAppDelegate *appDelegate = (PageFlipperAppDelegate *)[[UIApplication sharedApplication] delegate];
[(UINavigationController *)[[appDelegate window] rootViewController] setToolbarHidden:YES animated:YES];
[(UINavigationController *)[[appDelegate window] rootViewController] pushViewController:viewController animated:YES];
在我的 pageViewController 中 .....................
- (id)initWithManagedObjectContext:(NSManagedObjectContext *)initManagedObjectContext
{
if ((self = [super initWithNibName:@"PageView" bundle:nil]))
{
[self setManagedObjectContext:initManagedObjectContext];
dataSource = [[PagesDataSource alloc] initWithManagedObjectContext:[self managedObjectContext]];
}
return self;
}
最佳答案
陷阱场景:如果在同一个 .XIB 文件中有两个 UIViewController,并且 View 导出指向同一个 View ,则在加载 nib 时将引发 UIViewControllerHierarchyInconsistency 异常,例如通过调用其中一个的 .view 属性 View Controller 。
关于ios - UIViewControllerHierarchy不一致,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11877264/
我的应用程序在 iOS5 中运行良好,但当我切换到 iOS6 时,由于 UIViewControllerHierarchyInconsistency,它崩溃了。 错误如下所示: UIViewContr
我是一名优秀的程序员,十分优秀!