‘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;}解决方法 当我想要一个设置滚动视图显示在一个popover时,我出现了同样的错误.
这是我的原始代码,有关我改变以解决它的意见:
SettingsVIEwController *settingsVIEwController;UIStoryboard *storyboard = [UIStoryboard storyboarDWithname:@"Storyboard" bundle:nil]; settingsVIEwController = [storyboard instantiateVIEwControllerWithIDentifIEr:@"Settings"];CGRect contentRect = CGRectMake(10,10,320,700);// This entire object got deleted in the fixed versionUIVIEwController *popoverContent = [[UIVIEwController alloc] init];popoverContent.vIEw = settingsVIEwController.vIEw;popoverContent.contentSizeforVIEwInPopover = contentRect.size;// Instead of popoverContent I just put the settingsVIEwController in directly.UIPopoverController *popoverController = [[UIPopoverController alloc] initWithContentVIEwController:popoverContent];[popoverController presentPopoverFromrect:[sender frame] inVIEw:(UIbutton*)sender permittedArrowDirections:UIPopoverArrowDirectionleft animated:YES];
行popoverContent.vIEw = settingsVIEwController.vIEw是导致崩溃的原因(没有它,我的popover当然是空的).从UIVIEwControllerHIErarchyInconsistency错误的角度来看,我不应该重新分配它,然后将其添加到另一个视图控制器.
在你的情况下,我猜想pushVIEwController或代码中的其他地方发生了类似的事情.可以这样吗?
总结以上是内存溢出为你收集整理的ios – UIViewControllerHierarchyInconsistency全部内容,希望文章能够帮你解决ios – UIViewControllerHierarchyInconsistency所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)