[我试图通过父视图控制器设置ViewController,直到它显示可以提供回调,我使用PrepareForSegue
做到了这一点>
- (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if ([segue.identifier isEqualToString:@"newQuarter"]) { [segue.destinationViewController setParentViewController:self]; } }
崩溃使我收到错误消息:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Application tried to present modally an active controller.
所以我尝试使用另一种方法,并在触摸按钮时设置了新的视图控制器,
<< [- (IBAction) buttonClicked { NewViewController *newController = [[NewViewController alloc] init]; [newController setParentViewController:self]; [self presentViewController:newController animated:YES completion:nil]; }
但运气不好,它仍然给我同样的错误信息,有人可以请教吗?谢谢!
已解决问题,因为父视图控制器是tableViewController
,它已嵌入在navigationViewController
中。这就是为什么应该推举segue而不是执行模式转换的原因。
替换: