ios - App store 拒绝了我的应用程序崩溃,但它从未通过大量测试为我崩溃

标签 ios swift sprite-kit mfmailcomposeviewcontroller messageui

我将我的应用程序提交到应用程序商店,但他们拒绝了它,说当他们单击反馈按钮时应用程序崩溃了,该按钮是一个打开 MFMailComposeViewController 的按钮。我遇到的问题是我已经在模拟器和实际设备之间的许多设备上运行它,但我从来没有遇到过这个问题。我将在下面发布我调用的反馈按钮的功能,并且都连接到按钮(就像我说的,每次我测试它时它都工作得很好),我的问题是:我在代码中做错了什么只有他们才会崩溃的地方?

func giveFeedback()
{
    let email = ["info@website.com"]
    var fvc = view?.window?.rootViewController
    var cev = MFMailComposeViewController()
    cev.mailComposeDelegate = self
    cev.setToRecipients(email)
    cev.setSubject("MyApp")
    fvc?.presentViewController(cev, animated: true, completion: nil)
}
func mailComposeController(controller: MFMailComposeViewController!, didFinishWithResult result: MFMailComposeResult, error: NSError!)
{
    controller.dismissViewControllerAnimated(true, completion: nil)
}

此外,我已经导入了 MessageUI,并且在类中我有我的 MFMailComposeViewControllerDelegate

最佳答案

一件事是您不调用 canSendMail .我相信,如果您尝试在禁用邮件时显示 MFMailComposeViewController,您的应用程序将会崩溃。

在您的函数中,您可以像这样使用它:

func giveFeedback(contextViewController: UIViewController) {

    if MFMailComposeViewController.canSendMail() {
        let email = ["info@website.com"]
        var cev = MFMailComposeViewController()
        cev.mailComposeDelegate = self
        cev.setToRecipients(email)
        cev.setSubject("MyApp")
        contextViewController.presentViewController(cev, animated: true, completion: nil)
    }
}

但最好早点检查状态并仅在设备上启用电子邮件时才显示按钮...

关于ios - App store 拒绝了我的应用程序崩溃,但它从未通过大量测试为我崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32551443/

相关文章:

ios - 在选项卡栏 Controller 之前呈现 View

ios - 为什么不调用 searchBarTextDidEndEditing?

swift - 如何找到给定类型可用的所有属性和方法?

ios - Swift-通过应用程序使用数据

ios - Cocoapods:如何使用最新的 Swift 版本创建一个 pod?

ios - 尝试设置 UIPickerView 的数据源时出错

ios - 如何在单个 UITableViewCell 中显示多个(任意)数量的标签(标签)?

ios - Swift 和 Sprite Kit - 如何测量 Sprite 移动的总距离?

Swift:节点之间建立联系后,skaction 未执行?

ios - 将 SKScene 渲染到 SKTexture?