【发布时间】: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