gpt4 book ai didi

ios - MFMailComposeViewController 出现一秒钟然后消失

转载 作者:行者123 更新时间:2023-11-30 13:45:32 25 4
gpt4 key购买 nike

我已经按照 Swift Guide 完成了 MFMailComposeViewController() 的常规设置

https://developer.apple.com/library/prerelease/ios/documentation/MessageUI/Reference/MFMailComposeViewController_class/

但是当我运行此命令时,电子邮件会出现一瞬间,然后消失,并且我收到错误消息“MailCompositionService 意外退出”。

这是完整的代码

import Foundation
import UIKit
import MessageUI

class ViewController: UIViewController, MFMailComposeViewControllerDelegate {

@IBAction func showEmail(sender: AnyObject) {

let composeVC = MFMailComposeViewController()
composeVC.mailComposeDelegate = self
// Configure the fields of the interface.
composeVC.setToRecipients(["address@example.com"])
composeVC.setSubject("Hello!")
composeVC.setMessageBody("Hello from California!", isHTML: false)

// Present the view controller modally.
self.presentViewController(composeVC, animated: true, completion: nil)
}

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)
}}

最佳答案

这是 xcode 模拟器中的一个已知错误。它应该在您的设备上正常工作。

关于ios - MFMailComposeViewController 出现一秒钟然后消失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34984652/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com