I am trying to build my app and at one point I push a UIViewController and then I get this error. I am not exactly sure why.
'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];
In my pageViewController...................
- (id)initWithManagedObjectContext:(NSManagedObjectContext *)initManagedObjectContext
{
if ((self = [super initWithNibName:@"PageView" bundle:nil]))
{
[self setManagedObjectContext:initManagedObjectContext];
dataSource = [[PagesDataSource alloc] initWithManagedObjectContext:[self managedObjectContext]];
}
return self;
}