Is there a way to call code when a modal view is finished dismissing?
EDIT:
I’m sorry, I didn’t clarify earlier. I’m trying to dismiss a UIImagePickerController and then show a MFMailComposeViewController and attach the image data to the email. When I try to call
[self presentModalViewController: mailController]
right after
[self dismissModalViewController];
I get errors and such.
You use a delegate pattern for the modal view to inform whoever presented it when it’s finished.
MyModalViewController.h:
MyModalViewController.m:
ParentViewController.h:
ParentViewController.m:
EDIT:
I haven’t used
UIImagePickerController, but looking at the docs, it looks like you already have most of the code done for you, as there is an existingUIImagePickerControllerDelegateclass that has three different “dismissal” delegate callbacks (although one is deprecated). So you should make yourParentViewControllerclass (whatever that is) implement theUIImagePickerControllerDelegatepattern and then implement those methods. While each method will do something different (since you have to handle when the user actually selects an image, or if they cancel), they each will do the same thing at the end: calldismissModalViewControllerAnimated:to dismiss the picker.