How can I detect the end of the animation of a modal view (when I do a dismiss)? (I\'m talking about MFMailComposeViewController which is not created by myself...)
Thank
Your modal view controller has a -viewDidDisappear:
method that is automatically invoked whenever the view is removed from the screen. You can override this method in your modal view controller to do whatever you like.
Also, you may want to consider implementing the -viewDidAppear:
method in the view controller whose view gets revealed by your modal view disappearing.
Normally to be notified when an animation is complete you set a delegate by sending setAnimationDelegate: to the UIView class.
When a VC is dismissed using [someVC dismissModalViewControllerAnimated:YES]
you can't set the animation delegate, but if you send NO instead and do your own animation of the VC's view you can set the delegate and be notified when the animation is completed.
You can subclass MFMailComposeViewController and overload its -viewDidDisappear:
.
@interface MyCtrler : MFMailComposeViewController
@end
@implementation MyCtrler
-(void)viewDidDisappear:(BOOL)animated {
[super viewDidDisappear:animated];
// do anything you like
}
@end
I needed to do something after dismissing a modal view, and only when it is sure that the modal view is really gone (been completely dealloc-ed). So viewDidDisappear and its friends in the modal view were too early for me.
The easiest I found was to just delay my code with a NSTimer. When modal view calls its delegate and the delegate invokes removing the modal view, it also queues up the code to be run when the modal view is gone. The timing was something like 300ms or 400ms. (Is there a way to retrieve the actual timing from somewhere?)