Reputation: 149
I am getting following error when I try to present a UIViewController modally.
"Application tried to present modally an active controller".
I have read many posts on this in stackoverflow. Which explains about this error. I am aware that, this exception is thrown when UIViewController which is already presented, is attempted to show modally again.
My application logic is:
When app goes to background. I dismiss modal view controller using
[self dismissModalViewControllerAnimated:NO]
When app comes back to foreground, I show the controller again
[self presentModalViewController:viewController animated:NO]
This logic works fine on iPad with iOS 6.0.1, but fails with iPad Mini with iOS 6.0.2.
I appreciate any suggestions.
Upvotes: 2
Views: 2878
Reputation: 47069
I think that the best solution is to use presentViewControllerAnimated:completion:nil
and dismissViewControllerAnimated:completion:
for iOS6 or try to present the view controller after some delay (Call by method of NSTimer
).
[self presentViewController:YourVC animated:YES completion:nil];
and
[self dismissViewControllerAnimated:YourVC completion:nil];
Upvotes: 0