I tried to set the ViewController with the parent view controller, before it shows that it can provide callbacks, I did this with PrepareForSegue
- (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if ([segue.identifier isEqualToString:@"newQuarter"]) { [segue.destinationViewController setParentViewController:self]; } }
It crashed giving me an error message: Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Application tried to present modally an active controller.
So I tried using a different method and set up a new controller on the button by pressing up,
- (IBAction) buttonClicked { NewViewController *newController = [[NewViewController alloc] init]; [newController setParentViewController:self]; [self presentViewController:newController animated:YES completion:nil]; }
but no luck, he still gives me the same error message, can anyone ask for advice? Thanks!
ios objective-c segue modalviewcontroller viewcontroller
user1494994
source share