I have a container controller that handles 2 navigation controllers side by side. I sometimes need to move a bunch of view controllers from one navigation stack to the bottom of another navigation stack.
The problem is that I am getting a UIViewControllerHierarchyInconsistency
exception, which is new in iOS 5. I am not sure how to get around this. Using push / pop methods works fine, however I need to push things further up the stack, so I refer to the view controller array itself. Code:
- (void)swapViewController:(UIViewController *)controller { NSMutableArray *leftStack = [NSMutableArray arrayWithArray:_leftNavController.viewControllers]; NSMutableArray *rightStack = [NSMutableArray arrayWithArray:_rightNavController.viewControllers]; if ([leftStack containsObject:controller]) {
Full exception:
*** Terminating app due to uncaught exception 'UIViewControllerHierarchyInconsistency', reason: 'child view controller:<MyViewController: 0x6c4e7f0> should have parent view controller:<UINavigationController: 0x6a5d100> but requested parent is:<UINavigationController: 0x6a58c10>'
source share