Auf dem gleichen Viewcontroller können wir eine E-Mail oder eine Textnachricht senden, um Informationen an einen Freund zu senden. Die Textnachricht in App funktioniert vollständig. Aber für die E-Mail öffnet sich die E-Mail-App in meiner App mit allen Informationen, die ich schreiben wollte, aber es ist unmöglich, sie durch Drücken von Abbrechen abzuweisen, nichts passiert. Ich habe versucht, mc.mailComposeDelegate = self oder mc.delegate = self und MFMailComposeViewControllerDelegate ist auch an der Spitze. Ich schaute alles im Internet, ich habe keine Erklärung gefunden. mailComposeController wird nie aufgerufen! Haben Sie eine Idee?SWIFT - mailComposeDelegate nicht aufgerufen: Abbrechen von MFMailComposeViewController funktioniert nicht
class inviteAFriendViewController: UIViewController, MFMessageComposeViewControllerDelegate, MFMailComposeViewControllerDelegate {
@IBAction func emailButtonDidTouch(sender: AnyObject) {
sendEmail()
}
func sendEmail() {
let emailTitle = "text"
let messageBody = "text"
let toRecipents = [""]
let mc = MFMailComposeViewController()
//mc.mailComposeDelegate = self
mc.delegate = self
mc.setSubject(emailTitle)
mc.setMessageBody(messageBody, isHTML: false)
mc.setToRecipients(toRecipents)
presentViewController(mc, animated: true, completion: nil)
}
func mailComposeController(controller2: MFMailComposeViewController, didFinishWithResult result: MFMailComposeResult, error: NSError?) {
switch result.rawValue {
case MFMailComposeResultCancelled.rawValue:
print("Mail cancelled")
controller2.dismissViewControllerAnimated(true, completion: nil)
case MFMailComposeResultSaved.rawValue:
print("Mail saved")
controller2.dismissViewControllerAnimated(true, completion: nil)
case MFMailComposeResultSent.rawValue:
print("Mail sent")
controller2.dismissViewControllerAnimated(true, completion: nil)
case MFMailComposeResultFailed.rawValue:
print("Mail sent failure.")
controller2.dismissViewControllerAnimated(true, completion: nil)
default:
break
}
controller2.dismissViewControllerAnimated(true, completion: nil)
}
Oh mein Gott, es funktioniert, ich weiß nicht, wer du bist, aber danke 1000 mal! Einen schönen Tag noch! – Oscar