Show Modal UIViewController just after another one

By July 24, 2012Blog

You might come to a problem when you need to show new modal view controller just after another has been dismissed. And you want to preserve the animation even on dismiss.

Unfortunately it is not possible to call:

[self dismissModalViewControllerAnimated:TRUE];
 
[self presentModalViewController:picker animated:YES];
 

 

 As the second one will never show up.

@performSelector is the cure for our problem, just delay the call to the other modal view controller a bit:

[self dismissModalViewControllerAnimated:TRUE];
 
// schedule the open mail composer in a little delay
[self performSelector:@selector(sendMail) withObject:nil afterDelay: 0.45];

 

 Where in the sendMail function we call the obvious presentModalViewController on the mail picker controller.

Happy coding!