【问题标题】:MFMailComposerViewController not geting to didFinishWithResultMFMailComposeViewController 没有得到 didFinishWithResult
【发布时间】:2019-10-28 12:37:25
【问题描述】:

我创建了一个非常简单的项目,它使用 MFMailComposeViewController 进入邮件,发送按钮成功发送,但我没有进入函数 didFinishWithResult

我尝试过使用和不使用 UINavigationController 我试过 self.dismiss 和 controller.dismiss 在 didFinishWithResult 中放置一个断点。我从来没有到达那里

import UIKit
import MessageUI

class ViewController: UIViewController, MFMailComposeViewControllerDelegate {

    @IBAction func butTestMailTapped(_ sender: Any) {
        if !MFMailComposeViewController.canSendMail() {
            var alert = UIAlertView(title: "Alert", message: "Mail Server not available", delegate: nil, cancelButtonTitle: "ok", otherButtonTitles: "")
            alert.show()
            return
        }

        let composeVC = MFMailComposeViewController()
        composeVC.mailComposeDelegate = self

        // Configure the fields of the interface.
        composeVC.setToRecipients(["xxx@xx.xx.xx"])

        // Present the view controller modally.
        self.present(composeVC, animated: true, completion: nil)



    }

       func mailComposeController(controller: MFMailComposeViewController!, didFinishWithResult result: MFMailComposeResult, error: NSError!) {
            // Check the result or perform other tasks.

            // Dismiss the mail compose view controller.
           controller.dismiss(animated: true,completion: nil)
        }



    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
    }


}

【问题讨论】:

标签: swift


【解决方案1】:

您需要Doc的最新更新

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

【讨论】:

  • 谢谢,如此细微的变化,希望 Apple 更新整个文档,文本更改示例代码未更改
猜你喜欢
  • 1970-01-01
  • 2016-10-09
  • 1970-01-01
  • 2011-08-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多