gpt4 book ai didi

ios - MFMailComposeViewController 返回和发送按钮不起作用

转载 作者:行者123 更新时间:2023-11-28 14:34:37 24 4
gpt4 key购买 nike

我尝试使用 MFMailComposeViewController 在我的应用程序中发送电子邮件。

let email = "..."

let mailComposer = MFMailComposeViewController()

mailComposer.mailComposeDelegate = self
mailComposer.setToRecipients([email])

self.navigationController?.present(mailComposer, animated: true)

运行我的应用程序后,显示 Composer 屏幕,但未显示 cancelsend 按钮。我尝试了很多可能的解决方案,如在两个导航 Controller 中更改 tintColor。例如:

mailComposer.navigationBar.tintColor = .red

但“问题”仍然存在。

有什么想法吗?

最佳答案

请尝试这些代码

class TechSupportVC: UIViewController, MFMailComposeViewControllerDelegate {
let composeVC = MFMailComposeViewController()

override func viewDidLoad() {
super.viewDidLoad()

composeVC.mailComposeDelegate = self
composeVC.setToRecipients(["desiredEmail@gmail.com"])
composeVC.setSubject("My message")
}

func mailComposeController(_ controller: MFMailComposeViewController,
didFinishWith result: MFMailComposeResult,
error: Swift.Error?) {
controller.dismiss(animated: true, completion: nil)
}

@IBAction func sendPressed(_ sender: Any) {
guard MFMailComposeViewController.canSendMail() else {
showMailServiceErrorAlert()
return
}

composeVC.setMessageBody("Test credentials: \(firstAndLastNameTextField.text!)\nPhone: \(numberTextField.text!)\n\n\(messageTextView.text!)", isHTML: false)

self.present(composeVC, animated: true, completion: nil)
}

关于ios - MFMailComposeViewController 返回和发送按钮不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50986814/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com