gpt4 book ai didi

ios - 电子邮件已发送完毕,但发送电子邮件窗口未关闭?

转载 作者:行者123 更新时间:2023-11-30 12:28:35 25 4
gpt4 key购买 nike

我的问题是我编写了 emailwindow 并且它确实发送电子邮件,但是当它们发送或我想关闭窗口时,什么也没有发生。

这是我的代码:

import Foundation
import UIKit
import MessageUI


class ContactViewController: UIViewController, MFMailComposeViewControllerDelegate, UIAlertViewDelegate {

override func viewDidLoad() {
super.viewDidLoad()
}

let mail = MFMailComposeViewController()


@IBAction func email(_ sender: Any) {

if !MFMailComposeViewController.canSendMail() {
let warnung = UIAlertController(title: "Email konnte nicht gesendet werden", message: "Dein Gerät unterstützt leider keine Email-Funktion.", preferredStyle: .alert)
let action1 = UIAlertAction(title: "OK", style: .default, handler: nil)
warnung.addAction(action1)
self.present(warnung, animated: true, completion: nil)
return

} else {

mail.mailComposeDelegate = self
mail.setToRecipients(["team@example.com"])
mail.setSubject("Message to you")
mail.setMessageBody("Hello,\n", isHTML: false)

present(mail, animated: true, completion: nil)

func mailComposeController(_ controller: MFMailComposeViewController,
didFinishWithResult result: MFMailComposeResult, error: NSError?) {
mail.dismiss(animated: true, completion: nil)
print("Yes!")
}


}
}
}

这是邮件窗口的屏幕截图: Just click on this link!

最佳答案

@IBAction func email(_ sender: Any) {

if !MFMailComposeViewController.canSendMail() {
let warnung = UIAlertController(title: "Email konnte nicht gesendet werden", message: "Dein Gerät unterstützt leider keine Email-Funktion.", preferredStyle: .alert)
let action1 = UIAlertAction(title: "OK", style: .default, handler: nil)
warnung.addAction(action1)
self.present(warnung, animated: true, completion: nil)
return

} else {

mail.mailComposeDelegate = self
mail.setToRecipients(["team@example.com"])
mail.setSubject("Message to you")
mail.setMessageBody("Hello,\n", isHTML: false)

present(mail, animated: true, completion: nil)
}
}
}

func mailComposeController(_ controller: MFMailComposeViewController,
didFinishWithResult result: MFMailComposeResult, error: NSError?) {
mail.dismiss(animated: true, completion: nil)
print("Yes!")
}

关于ios - 电子邮件已发送完毕,但发送电子邮件窗口未关闭?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43871113/

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