当前位置 : 主页 > 手机开发 > 其它 >

swift – MFMailComposeViewController在iOS9下立即消失

来源:互联网 收集:自由互联 发布时间:2021-06-11
一旦我出现我的MFMailComposeViewController它就会被解雇,但是错误: viewServiceDidTerminateWithError: Error Domain=_UIViewServiceInterfaceErrorDomain Code=3 “(null)” UserInfo={Message=Service Connection Interrupted} 到底是
一旦我出现我的MFMailComposeViewController它就会被解雇,但是错误:

viewServiceDidTerminateWithError: Error Domain=_UIViewServiceInterfaceErrorDomain Code=3 “(null)” UserInfo={Message=Service Connection Interrupted}

到底是怎么回事?

非常重要的说明

它在iOS8下运行良好.

我不能帮助你,因为你没有发布任何代码,但这是iOS9上的MailComposeController的工作副本,在我的应用程序中使用它没有任何问题.重要的是,您的类符合MFMailComposeViewControllerDelegate.请注意,sendMail方法与项目中的按钮相关

@IBAction func sendMail(sender: AnyObject) {

    let mailComposeViewController = configuredMailComposeViewController()

    if MFMailComposeViewController.canSendMail() {
        self.presentViewController(mailComposeViewController, animated: true, completion: nil)
    } else {
        self.showSendMailErrorAlert()
    }
}


func configuredMailComposeViewController() -> MFMailComposeViewController {
    let mailComposerVC = MFMailComposeViewController()
    mailComposerVC.mailComposeDelegate = self 
    mailComposerVC.setToRecipients(["yourMail@goesHere"])

    return mailComposerVC
}

func showSendMailErrorAlert() {

   print("There was an error.")
    //In case of error with email account on device, you should implement an alert here

}

func mailComposeController(controller: MFMailComposeViewController, didFinishWithResult result: MFMailComposeResult, error: NSError?) {
    controller.dismissViewControllerAnimated(true, completion: nil)
}
网友评论