1
我有一個簡單的iOS10應用程序正在構建。我建立了一個頁面,用戶可以添加主題行和電子郵件的正文。當點擊發送電子郵件按鈕時,MFMailViewCompose正常啓動,如果我點擊發送電子郵件發送。但是,MFMailViewCompose不會在發送或取消時關閉。MFMailViewCompose不會關閉
下面是代碼
import UIKit
import MessageUI
class EnglishEmailHelpdeskVC: UIViewController, MFMailComposeViewControllerDelegate {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
//Helpdesk Email Subject Line and Body.
@IBOutlet var EmailHelpdeskSubjectLine: UITextField!
@IBOutlet var EmailHelpdeskBody: UITextView!
var MailControllerCompose:MFMailComposeViewController!
//Helpdesk Send Email Button.
@IBAction func EmailHelpdeskSendButton(_ sender: AnyObject) {
let HDSubjectLine = EmailHelpdeskSubjectLine.text
let HDBody = EmailHelpdeskBody.text
MailControllerCompose = MFMailComposeViewController()
MailControllerCompose.mailComposeDelegate = self
MailControllerCompose.setToRecipients(["[email protected]"])
MailControllerCompose.setSubject(HDSubjectLine!)
MailControllerCompose.setMessageBody(HDBody!, isHTML: false)
self.present(MailControllerCompose, animated: true, completion: nil)
}
@nonobjc func MFMailComposeViewContoller(controller: MFMailComposeViewController,didFinishWithResult result:MFMailComposeResult, error: NSError?){
MailControllerCompose.dismiss(animated: true, completion: nil)
}
}
請幫幫忙!
其他人似乎來到了同樣的結論:http://stackoverflow.com/a/ 58603分之39623586 –