Take the 2-minute tour ×

I have an app that uses modal view controllers for various purposes. Most importantly for this question, we use a modal controller to display the login screen when a user is logged out.

The issue I ran into is that it appears that presentModalViewController:animated: will fail silently if another modal controller is being animated on or off screen when the call is made. It will print to the debug console with a warning, but the method itself doesn't return a BOOL or throw an exception, so I can't seem to check in code whether it failed so I can retry it in a second.

Is there some way to detect that the controller failed to display immediately after calling this method?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

So as I was typing this question, I realized I could check presentingViewController (or parentViewController) to see if it was displayed, and if nil, try again.

Tested and it works. Figured I'd post and answer the question anyway for others to find that may run into a similar issue.

Aa few more things I noticed in testing:

  • It looks like if the modal view is not displayed with an animation, it will be successful even if another modal view is animating when you make the call.

  • Calling dismissModalViewControllerAnimated:NO on the controller you are displaying off of, before presenting the modal controller with animation, will also allow it to complete successfully even if another controller is animating.

share|improve this answer
add comment

Your Answer


