无法使用dismiss退出邮件编辑器(动画化:true,完成:nil),并且dismissViewControllerAnimated不会作为选项出现

问题描述 投票:0回答:1

我已经导入了MessageUI并创建了一个扩展以包括MFMailComposeViewControllerDelegate,其中包括dismiss(动画:true,完成:nil),并且这不会关闭弹出来发送消息的VC,但这是出现的唯一选项键入关闭时。我无法确定更新的Swift版本是否需要这样做,因为所有其他示例都显示dismissViewControllerAnimated。不确定我缺少什么?

动作按钮代码

    @IBAction func sendTapped(_ sender: UIButton) {

    let toRecipient = ["\(Constants.SubmitFeedback.feedbackEmail)"]

    let mc = MFMailComposeViewController()
    mc.mailComposeDelegate = self

    mc.setToRecipients(toRecipient)
    mc.setSubject("Feedback for Gallery App")

    mc.setMessageBody("Name: \(String(describing: nameTextField.text!)) \nEmail: \(String(describing: emailTextField.text!)) \n\nMessage: \n\(String(describing: messageTextField.text!))", isHTML: false)

    self.present(mc, animated: true, completion: nil)

}

带有'dismiss'命令的扩展名

extension FeedViewController: MFMailComposeViewControllerDelegate {

func mailComposeController(_ controller: MFMailComposeViewController, didFinishWith result: MFMailComposeResult, error: Error?) {
    switch result.rawValue {
    case MFMailComposeResult.cancelled.rawValue:
        print("Cancelled")
    case MFMailComposeResult.failed.rawValue:
        print("Failed")
    case MFMailComposeResult.saved.rawValue:
        print("Saved")
    case MFMailComposeResult.sent.rawValue:
        print("Sent")
    default:
        break
    }

    dismiss(animated: true, completion: nil)
}

}
ios swift mfmailcomposeviewcontroller mfmailcomposer
1个回答
0
投票
© www.soinside.com 2019 - 2024. All rights reserved.