我试图在显示它可以提供回调之前使用父视图控制器设置 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];
}
但是没有运气,它仍然给我同样的错误信息,有人可以请教吗?谢谢!