电子邮件已完成但发送电子邮件窗口未关闭

时间:2017-05-09 13:23:54

标签: ios swift mfmailcomposeviewcontroller

我的问题是我编写了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!

1 个答案:

答案 0 :(得分:0)

#ifdef Enable_Analytics
  // Code statements which has to executed only if Enable_Analytics is defined
#endif