I have a view controller presented modally to let people sign up for a newsletter that then calls MFMailComposer. Once the mail is sent, I want to be able to dismiss the modal view controller after I click Send on the email window. Is this possible?
This was incorrectly marked a duplicate because my code is structured as follows:
CustomViewController calls ModalViewController ModalViewController calls MailComposer After user clicks send the ModalViewController needs to be dismissed.
You should dismiss the controller in
mailComposeController(_:didFinishWith:error:)after you checked that theMFMailComposeResultissent.Remember that you should set the delegate of the mail compose view controller and your view controller should conform to the
MFMailComposeViewControllerDelegateprotocol: