MFMailComposeViewController in Swift

前端 未结 5 744
没有蜡笔的小新
没有蜡笔的小新 2021-02-03 21:36

This is sample code:

import UIKit
import MessageUI

class ViewController: UIViewController, MFMailComposeViewControllerDelegate {

    @IBAction func showEmail(s         


        
5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-03 22:18

    in Swift 2.0 do this:

    func mailComposeController(controller: MFMailComposeViewController, didFinishWithResult result: MFMailComposeResult, error: NSError?) {
            switch result.rawValue {
            case MFMailComposeResultCancelled.rawValue:
                print("Mail cancelled")
            case MFMailComposeResultSaved.rawValue:
                print("Mail saved")
            case MFMailComposeResultSent.rawValue:
                print("Mail sent")
            case MFMailComposeResultFailed.rawValue:
                print("Mail sent failure: \(error!.localizedDescription)")
            default:
                break
            }
            controller.dismissViewControllerAnimated(true, completion: nil)
        }
    

提交回复
热议问题