Is there a way to know when the dismissModalViewControllerAnimated is initiated and when it is completed (such as the idiom for viewWillAppear and viewDidAppear)? Unlike other animations, this one doesn't seem to have a delegate that tells you.
Yes, and easier than you think.
When dismissModalViewControllerAnimated: is called, the underlying view (the one about to appear) will receive a viewWillAppear message and a viewDidAppear message.
Caveat: make sure your view controllers are hooked up properly or these messages get lost.
I am afraid viewWillAppear and viewDidAppear don't always work. on iPhone they do, on iPad they may not. if the UIViewController presented is not presented in full screen (if it is presented as a form sheet for example) the parent view will not receive the viewWillAppear or viewDidAppear lifecycle functions. unfortunately the only way i found is to make my own delegate message to be called when the dismissModalViewControllerAnimated is called (ether by reference or with a notification)
You can use the view appearance methods. And if you need something to happen after the animation completes, you can use [object performSelector:@selector(selector) withObject:anotherObject afterDelay:0]
. I don't know exactly why, but the action will be scheduled on the current run loop, but after the animation completes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With