加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

swift – MFMailComposeViewController在iOS9下立即消失

发布时间:2020-12-14 04:30:09 所属栏目:百科 来源:网络整理
导读:一旦我出现我的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)
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读