gpt4 book ai didi

ios - MFMailComposeViewController 在 iOS 10.2 上的 presentViewController 上崩溃

转载 作者:行者123 更新时间:2023-11-28 06:26:33 25 4
gpt4 key购买 nike

好吧,这是一个非常小的问题,我已经花了几个小时研究并试图找出应用程序崩溃的原因。

假设我有两个 View Controller VC1、VC2,我正在从 VC2 调用 MFMailComposeViewController

到目前为止,我已经尝试从 VC1 过渡到 VC2..

  1. 通过performSegueIdentifier
  2. 通过 Storyboard ID
  3. 通过 Storyboard IDUINavigationController(rootViewController: vc2)

但没有任何效果。我什至尝试将 UINavigationViewController 嵌入到 VC2 中,但也没有成功。

下面是VC2中的IBAction方法

@IBAction func sendEmail(sender: AnyObject) {
if MFMailComposeViewController.canSendMail() {
let mailComposerVC = configuredMailComposeViewController()
presentViewController(mailComposerVC, animated: true, completion: nil) // CRASH
} else {
showSendMailErrorAlert()
}
}


func configuredMailComposeViewController() -> MFMailComposeViewController {

let mailComposerVC = MFMailComposeViewController()
mailComposerVC.mailComposeDelegate = self

mailComposerVC.setToRecipients(["abc@abc.com"])
mailComposerVC.setSubject("Reg: ")

return mailComposerVC
}

func showSendMailErrorAlert() {
let alert = UIAlertController(title: "Could Not Send Email", message: "Your device could not send e-mail. Please check e-mail configuration and try again.", preferredStyle: .Alert)
presentViewController(alert, animated: true, completion: nil)
}

所有 channel 和事件引用资料也都不错。

崩溃日志

[__NSCFNumber pointSize]: unrecognized selector sent to instance 0xb0000000000000e5
2017-01-16 16:52:55.887082 Sample[2507:671461] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFNumber pointSize]: unrecognized selector sent to instance 0xb0000000000000e5'

已解决:

问题出在自定义导航栏上。我在呈现 MFMailComposeViewController 时重置了 UINavigationBar 外观并将其重新设置为关闭。 This帖子帮我解决了。

我在全局文件中创建了以下两个方法。

static func applyGlobalNavigationBarAppearance() {
UINavigationBar.appearance().barTintColor = UIColor.blueColor()
UINavigationBar.appearance().tintColor = UIColor.whiteColor()
UINavigationBar.appearance().titleTextAttributes = [NSForegroundColorAttributeName : UIColor.whiteColor(), NSFontAttributeName: UIFont.systemFontSize()]
}

static func applyMailNavigationBarAppearance() {
UINavigationBar.appearance().barTintColor = UIColor.whiteColor()
UINavigationBar.appearance().tintColor = UIColor.whiteColor()
UINavigationBar.appearance().titleTextAttributes = nil
}

最佳答案

奇怪!我的猜测是您通过 UIAppearance 设置了一些东西(字体?),并且邮件编辑器是第一次引用此外观属性。您的项目是否使用 UIAppearance(例如 UINavigationBar.appearance)?如果是这样,请暂时将它们注释掉。查看是否解决了问题,然后找出问题所在。

关于ios - MFMailComposeViewController 在 iOS 10.2 上的 presentViewController 上崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41686601/

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