简体   繁体   English

MFMailComposeViewController 没有被解雇 - Swift,Xcode

[英]MFMailComposeViewController is not dismissing - Swift, Xcode

I'm currently trying to implement MFMailComposeViewController .我目前正在尝试实现MFMailComposeViewController Everything is working fine, except after sending an email or clicking cancel, the MFMailComposeViewController does not dismiss.一切正常,除了发送电子邮件或单击取消后, MFMailComposeViewController不会关闭。 I've looked at similar StackOverflow threads and attempted to implement those solutions, but they have not resolved my issue.我查看了类似的 StackOverflow 线程并尝试实现这些解决方案,但它们并没有解决我的问题。 I feel like the issue may not lie within the func mailComposeController , but within the rest of my code.我觉得问题可能不在于func mailComposeController ,而在于我的代码的其余部分。 Any help would be greatly appreciated.任何帮助将不胜感激。

My code:我的代码:

   if MFMailComposeViewController.canSendMail() {
        let vc = MFMailComposeViewController()
        vc.delegate = self
        vc.mailComposeDelegate = self
        vc.setSubject("Contact Us/Feedback")
        vc.setToRecipients(["test@gmail.com"])
        present(vc, animated: true)
    }
    else {
        if let url = URL(string: "https://www.google.com") {
        let safariVC = SFSafariViewController(url: url)
                
        present(safariVC, 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)
    }
}

Thanks!谢谢!

Change改变

func mailComposeController(controller: MFMailComposeViewController,
     didFinishWithResult result: MFMailComposeResult, error: NSError?) {

To

func mailComposeController(_ controller: MFMailComposeViewController, 
     didFinishWith result: MFMailComposeResult, error: Error?) {

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM