无法在 Swift 3.0 中关闭 MFMailComposeViewController



按取消或发送按钮后无法关闭MFMailComposeViewController。我已经在我的班级中添加了MFMailComposeViewControllerDelegate,但仍然不起作用?

这是我的代码:

func sendEmail() {
let MailVC = MFMailComposeViewController()
MailVC.mailComposeDelegate = self
MailVC.setToRecipients(["(emailLabel?.text)"])
MailVC.setSubject("Set your subject here!")
MailVC.setMessageBody("Hello this is my message body!", isHTML: false)
// Present the view controller modally.
self.present(MailVC, animated: true, completion: nil)
}
func mailComposeController(controller: MFMailComposeViewController,
didFinishWithResult result: MFMailComposeResult, error: NSError?) {
// Dismiss the mail compose view controller.
controller.dismiss(animated: true, completion: nil)
}

委托方法签名错误。controller参数之前缺少_。试试这个。

public func mailComposeController(_ controller: MFMailComposeViewController, didFinishWith result: MFMailComposeResult, error: Error?) {
// Dismiss the mail compose view controller.
controller.dismiss(animated: true, completion: nil)
}

并确保这一点。

class ViewController: UIViewController ,MFMailComposeViewControllerDelegate

相关内容

  • 没有找到相关文章

最新更新