I'm using MFMailComposeViewController
in a view controller with the following code:
if !MFMailComposeViewController.canSendMail() {
return
}
let mailComposeViewController = MFMailComposeViewController()
mailComposeViewController.mailComposeDelegate = self
present(mailComposeViewController, animated: true)
And:
extension MyViewController : MFMailComposeViewControllerDelegate {
private func mailComposeController(_ controller: MFMailComposeViewController, didFinishWith result: MFMailComposeResult, error: Error?) {
controller.dismiss(animated: true, completion: nil)
}
}
The MFMailComposeViewController
shows as expected, but has the following behavior:
MFMailComposeViewController
This is Xcode 11.2, iOS 13.2, Swift 4.
How can I fix this?
In this code
extension MyViewController : MFMailComposeViewControllerDelegate {
private func mailComposeController(_ controller: MFMailComposeViewController, didFinishWith result: MFMailComposeResult, error: Error?) {
controller.dismiss(animated: true, completion: nil)
}
}
Delete the keyword private
. It hides the method from Cocoa so that it will never be called.