I can't just do
[myViewController dismissModalViewControllerAnimated:YES];
[myViewController presentModalViewController:nextModalViewController animated:YES];
one after the other, because then the two animation blocks try to affect the same references simultaneously and things break badly.
So what I need to do is make the latter call only after the first animation has finished. But there's no UIViewControllerDelegate
method like didDismissModalViewController
. What should I do?
What's wrong with just subclassing the view controller (if you haven't already) and doing this:
- (void) viewDidDisappear: (BOOL) animated
{
[super viewDidDisappear: animated];
[myViewController presentModalViewController:nextModalViewController animated:YES];
}
I'm not sure how you are handling your references to the view controllers, but the point I'm trying to make is just catch the viewDidDisappear for the model view controller that is sliding off.
It's a bit hacky (ok, maybe a lot hacky), but you could simply present the second one after a fixed delay:
[myViewController performSelector:@selector(showSecondModalView) withObject:nil afterDelay:0.5];
(or whatever the animation duration turns out to be).