我需要在UINavigationController层次结构中从父视图控制器转换到孙视图控制器。我怎样才能做到这一点?我试过这些......
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];
这首先起作用,但当我回来再试一次时会导致崩溃
NOZMenuTVController *menuvc = [self.storyboard instantiateViewControllerWithIdentifier:@"menuViewController"];
[self.navigationController pushViewController:menuvc animated:NO];
NOZPaymentViewController *payvc = [self.storyboard instantiateViewControllerWithIdentifier:@"paymentViewController"];
[self.navigationController pushViewController:payvc animated:YES];
答案 0 :(得分:0)
第二种解决方案有效。它没有提前工作,因为在子控制器的某个地方,我正在设置UINavigationController的委托(在dealloc期间将navctrl的委托设置为nil没有帮助),当用户回来时,导航控制器本身就不再存在了。