How to prevent present modally an active controller?
There may be another case:
Is the target ViewController presented after some user click on a button? The user may be clicking twice, making two operations and opening the same ViewController twice, if you have a shared instance of the said ViewController.
Try disabling the button while the operation is in progress, display a progress indicator, and so on.
I have found kind of solution for this
- (IBAction)menuButtonPressed:(id)sender
{
[self.parentViewController presentViewController:self.menuAlert animated:YES completion:nil];
}
Alert view sometimes appears on menuVC, but it doesn't crash application and work normally. Answer was found there: Warning :-Presenting view controllers on detached view controllers is discouraged
I think u will need to dismiss the LAST viewcontroller first before going back by present modal segue, the viewcontroller is active, so it crash:
Use this after call segue from mainVC or something u wanted to go back:
[self dismissViewControllerAnimated:NO completion:nil]
or
[[self presentingViewController] dismissViewControllerAnimated:NO completion:nil]
or use push segue, it auto add a back button that automatically add back function