相关疑难解决方法(0)

UIViewControllerHierarchyInconsistency

我正在尝试构建我的应用程序,有一次我推了一个UIViewController然后我得到了这个错误.我不确定为什么.

'UIViewControllerHierarchyInconsistency',原因:'视图一次只能与一个视图控制器关联!视图>与...相关联.在将此视图与.关联之前清除此关联.

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];
Run Code Online (Sandbox Code Playgroud)

在我的pageViewController ...................

- (id)initWithManagedObjectContext:(NSManagedObjectContext *)initManagedObjectContext
{
    if ((self = [super initWithNibName:@"PageView" bundle:nil]))
    {
        [self setManagedObjectContext:initManagedObjectContext];
        dataSource = [[PagesDataSource alloc] initWithManagedObjectContext:[self managedObjectContext]];
    }
    return self;
}
Run Code Online (Sandbox Code Playgroud)

ios

15
推荐指数
2
解决办法
2万
查看次数

标签 统计

ios ×1