0

我正在开发一个可以在所有部署目标模拟器 (5.0-6.1) 以及我的 iPhone 3GS、4、4S 和第 2 代 iPad 上运行的应用程序。我今天有机会尝试在 iPad Mini 上运行它。我在任何地方工作,除非我尝试使用 MFMailComposeViewController 对象发送电子邮件,这会导致它崩溃并出现异常。

我直接使用 MailComposer 示例项目中的代码,但它在调用 presentModalViewController:animated: 时总是崩溃。所以我尝试了 presentViewController:animated:completion: 因为另一种方法已被弃用,但它仍然不起作用。

我链接到 MessageUI.framework 导入了类:

#import <MessageUI/MessageUI.h>
#import <MessageUI/MFMailComposeViewController.h>

委托已设置。这是代码:

-(void)displayComposerSheet
{
    MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
    picker.mailComposeDelegate = self;

    [picker setSubject:@"Contact Email"];

    // Set up recipient
    NSArray *toRecipients = [NSArray arrayWithObject:@"info@foo.bar"];
    [picker setToRecipients:toRecipients];

    //  [self presentModalViewController:picker animated:YES];
    [self presentViewController:picker animated:YES completion:NULL];
}

iPad Mini 中可能存在导致此问题的错误吗?我没有任何其他可以试用的新设备,所以我不确定它是小问题还是更大的问题。任何帮助将不胜感激,因为我已准备好提交给 Apple,但我肯定不想因为崩溃的错误而这样做。

4

2 回答 2

1

尝试包装您的 MFMailComposeViewController 代码

if ( [MFMailCompseViewController canSendMail])

我猜该设备上没有邮件设置。

于 2013-02-11T22:27:37.070 回答
1

可能是尚未设置邮件帐户或由于某些其他原因无法发送电子邮件。

一定+ (BOOL)canSendMail要先调用 MFMailComposeViewController 的函数。

于 2013-02-11T22:27:56.550 回答