MFMessageComposeViewController cancel button not working

前端 未结 6 493
慢半拍i
慢半拍i 2021-01-17 10:42

I use this block to send message to the contacts, after sending, the back button is there, but when I touch it nothing happens. Please help me out :)

-(IBAct         


        
6条回答
  •  逝去的感伤
    2021-01-17 11:24

    Here's the answer for Swift 4, iOS 11

    func mailComposeController(_ controller: MFMailComposeViewController, didFinishWith result: MFMailComposeResult, error: Error?) {
            print("Emailing attempt, error="+(error?.localizedDescription)!)        
            switch (result){
            case MFMailComposeResult.cancelled:
                print("Mail cancelled");
                break;
            case MFMailComposeResult.saved:
                print("Mail saved");
                break;
            case MFMailComposeResult.sent:
                print("Mail sent");
                break;
            case MFMailComposeResult.failed:
                print("Mail sent failure: %@", error?.localizedDescription);
                break;
            default:
                break;
            }
            // Close the Mail Interface
            controller.dismiss(animated: true)
        }
    

提交回复
热议问题