gpt4 book ai didi

ipad - MFMailComposeViewController-iPad

转载 作者:行者123 更新时间:2023-12-03 09:00:10 32 4
gpt4 key购买 nike

我已经设置了MFMailComposeViewController,它在iPhone上正常工作,但是在iPad上崩溃了,并说:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Application tried to present a nil modal view controller on target...

那么,为什么要创建一个零模态 View 呢?
    MFMailComposeViewController *message = [[MFMailComposeViewController alloc] init];
[message setMessageBody:@"My message here" isHTML:NO];
[message setToRecipients:[NSArray arrayWithObject:@"my@domain.com"]];
[message setSubject:@"Request Info"];
message.mailComposeDelegate = self;
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
message.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentModalViewController:message animated:YES];
[message release];

有任何想法吗?

最佳答案

MFMailComposeViewController这样的消息由于某种原因未创建,因此具有nil值。在显示它之前检查它是否为零(尽管此解决方法不能回答这里出了什么问题...)。

您还应该在尝试使用+canSendMail方法创建和显示邮件之前,检查邮件编写器是否可以发送邮件(例如,如果设备上未设置任何邮件帐户,它将返回NO):

 if ([MFMailComposeViewController canSendMail]){
// Create and show composer
}
else{
// Show some error message here
}

关于ipad - MFMailComposeViewController-iPad,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4987703/

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