【发布时间】:2020-11-25 00:01:37
【问题描述】:
我目前正在尝试实现MFMailComposeViewController。一切正常,除了发送电子邮件或单击取消后,MFMailComposeViewController 不会关闭。我查看了类似的 StackOverflow 线程并尝试实现这些解决方案,但它们并没有解决我的问题。我觉得问题可能不在于func mailComposeController,而在于我的代码的其余部分。任何帮助将不胜感激。
我的代码:
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)
}
}
谢谢!
【问题讨论】:
标签: ios swift xcode mfmailcomposeviewcontroller