How do I know when the rejectModalViewControllerAnimated function is triggered, and when it is done?

Is there a way to find out when the rejectModalViewControllerAnimated function is triggered and when it is completed (for example, the idiom for viewWillAppear and viewDidAppear)? Unlike other animations, this one doesn't seem to have a delegate that tells you.

+6
objective-c iphone cocoa-touch uikit
source share
3 answers

Yes, and easier than you think.

When calling the offsetModalViewControllerAnimated: function, the base view (the one that should appear) will receive a viewWillAppear message and a viewDidAppear message.

Caution: make sure your view controllers are connected correctly or these messages are lost.

+10
source share

I am afraid that viewWillAppear and viewDidAppear do not always work. on the iPhone they do, on the iPad they cannot. if the presented UIViewController is not presented in full screen mode (if it is presented as a form sheet, for example), the parent view will not receive the viewWillAppear or viewDidAppear life cycle functions. unfortunately, the only way I found is to get my own delegate message to be called when the call to rejectModalViewControllerAnimated is called (broadcast by reference or with notification)

+5
source share

You can use appearance methods. And if you need something to happen after the animation finishes, you can use [object performSelector:@selector(selector) withObject:anotherObject afterDelay:0] . I do not know exactly why, but the action will be planned in the current execution loop, but after the animation is complete.

+1
source share

All Articles