gpt4 book ai didi

iphone - PresentModalViewController 使我的应用程序崩溃

转载 作者:行者123 更新时间:2023-12-03 20:21:43 24 4
gpt4 key购买 nike

我知道,这是最简单的事情之一。但几天来我一直在努力反对这一点。我过去已经做过很多次了,但由于某种原因,尝试呈现模态视图 Controller 只会使应用程序崩溃到黑屏。控制台中没有报告任何内容。我希望有人可能遇到过这个问题并提供一些建议。

此代码是从 UIViewController 类调用的:

MFMailComposeViewController *controller = [[MFMailComposeViewController alloc] init];
controller.mailComposeDelegate = self;
[controller setSubject:@"test subject"];
[controller setMessageBody:@"this is the message body" isHTML:NO];
[self presentModalViewController:controller animated:YES];

最佳答案

正如安德鲁在评论中指出的那样,你检查过吗

+[MFMailComposeViewController canSendMail]

在尝试推送 View Controller 之前?如果此方法返回 NO,则 MFMailComposeViewController 的行为未明确定义(在模拟器上运行时也可能出现这种情况,尽管我不确定)。来自文档:

Before using this class, you must always check to see if the current device is configured to send email at all using the canSendMail method. If the user’s device is not set up for the delivery of email, you can notify the user or simply disable the email dispatch features in your application. You should not attempt to use this interface if the canSendMail method returns NO.

您是否尝试过推送另一个 View Controller ?这会让您的应用程序崩溃吗?

关于iphone - PresentModalViewController 使我的应用程序崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1082954/

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