I was trying to set the ViewController with a parent view controller before it shows show that it can provide call backs, I done this using PrepareForSegue
- (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier isEqualToString:@"newQuarter"])
{
[segue.destinationViewController setParentViewController:self];
}
}
It crashed giving me the error message: Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Application tried to present modally an active controller.
So I tried using another method and set up a new view controller on the button touches up,
- (IBAction) buttonClicked
{
NewViewController *newController = [[NewViewController alloc] init];
[newController setParentViewController:self];
[self presentViewController:newController animated:YES completion:nil];
}
but with no luck it is still giving me the same error message, can anyone please advice? Thanks!
Resolved the problem, since the parent view controller is a tableViewController
, which it was embedded in a navigationViewController
. That's why the segue should be pushed rather then performing modal transition.