I need to transition from a parent view controller to grandchild view controller in a UINavigationController hierarchy. How can I do that? I tried these ...
NSMutableArray *vcs = [[self.navigationController viewControllers] mutableCopy];
// menuvc is next
NOZMenuTVController *menuvc = [self.storyboard instantiateViewControllerWithIdentifier:@"menuViewController"];
[vcs addObject:menuvc];
// payvc comes after menu vc as in a master detail relationship
NOZPaymentViewController *payvc = [self.storyboard instantiateViewControllerWithIdentifier:@"paymentViewController"];
[vcs addObject:payvc];
// This causes a crash
[self.navigationController setViewControllers:vcs animated:YES];
This works at first but then causes crash when I come back and try again
NOZMenuTVController *menuvc = [self.storyboard instantiateViewControllerWithIdentifier:@"menuViewController"];
[self.navigationController pushViewController:menuvc animated:NO];
NOZPaymentViewController *payvc = [self.storyboard instantiateViewControllerWithIdentifier:@"paymentViewController"];
[self.navigationController pushViewController:payvc animated:YES];
The second solution works. It did not work earlier because somewhere in child controllers, I was setting the delegate for UINavigationController (setting the delegate for navctrl to nil during dealloc did not help) and when user came back, the nav controller was not itself anymore.