Iphone MFMailComposer挂起应用程序-无崩溃报告-在用户升级iOS后发生

Iphone MFMailComposer挂起应用程序-无崩溃报告-在用户升级iOS后发生,iphone,ios,objective-c,ipad,Iphone,Ios,Objective C,Ipad,编辑:我最终联系了苹果DTS。在我提供了一个受影响用户的stackshot后,DTS决定我应该向Apple BugReporter提交一个bug。所以,在这一点上,我认为这是MFMailComposer的一个问题,但它还没有解决。苹果病毒编号为13602051 我有一个bug,在一个应用程序中不断出现 一些升级iOS版本的用户报告说,他们无法再使用我的应用程序中的电子邮件导出,该应用程序使用MFMailComposer。应用程序冻结,不会生成崩溃报告 我的代码非常简单,我无法重现报告的bug,但

编辑:我最终联系了苹果DTS。在我提供了一个受影响用户的stackshot后,DTS决定我应该向Apple BugReporter提交一个bug。所以,在这一点上,我认为这是MFMailComposer的一个问题,但它还没有解决。苹果病毒编号为13602051

我有一个bug,在一个应用程序中不断出现

一些升级iOS版本的用户报告说,他们无法再使用我的应用程序中的电子邮件导出,该应用程序使用MFMailComposer。应用程序冻结,不会生成崩溃报告

我的代码非常简单,我无法重现报告的bug,但许多用户现在说这是在iOS更新之后发生的。代码如下:

// using ARC, so no reference counting
MFMailComposeViewController* controller = [[MFMailComposeViewController alloc] init];
controller.mailComposeDelegate = self;
@autoreleasepool {
  if (gpxFilePath) {
    NSData *gpx = [NSData dataWithContentsOfFile:gpxFilePath];
    [controller addAttachmentData:gpx mimeType:@"text/gpx" fileName:[self cleanFileName]];
    gpx = nil;
  }
}
[controller setSubject:subject];
[controller setMessageBody:body isHTML:YES];
[[MAP_APP_DELEGATE mainController] presentModalViewController:controller animated:YES];

调用此命令后,会出现电子邮件视图,但没有响应。

我正在使用iOS 6.1的下一个代码,它对我有效

if ([MFMailComposeViewController canSendMail]) {
    MFMailComposeViewController *mailer = [[MFMailComposeViewController alloc]init];
    mailer.mailComposeDelegate = self;
    [mailer setSubject:@"subject"];
    User *user = [user_array objectAtIndex:1];
    NSArray *toRecipients = [NSArray arrayWithObjects:@"mail address", nil];
    [mailer setToRecipients:toRecipients];
    NSArray *cc = [NSArray arrayWithObjects:@"mail address", nil];
    [mailer setCcRecipients:cc];
    NSDictionary *dic = [one array objectAtIndex:0];

    NSString *description = [dic objectForKey:@"Description"];

    NSString *emailBody = description;

    [mailer setMessageBody:emailBody isHTML:NO];
    [self presentViewController:mailer animated:YES completion:nil];
    [mailer release];
}
else
{
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Failure"
                                                    message:@"Your device doesn't support the composer sheet"
                                                   delegate:nil
                                          cancelButtonTitle:@"OK"
                                          otherButtonTitles: nil];
    [alert show];
    [alert release];
}
请记住,模拟器无法发送电子邮件,因此在这种情况下将显示警报视图

注1:在iOS 6.0中不推荐使用presentModalViewController


注2:尝试发送没有数据的电子邮件,以检查这是否是问题的原因

这应该可以解决您的问题

[[MAP_APP_DELEGATE mainController] presentModalViewController:controller animated:YES];

 controller = nil;

自动释放池可能是一个问题。添加附件时,该池可能会对邮件生成器创建的自动删除对象产生影响。我会把它处理掉的。然后用alloc/init替换自动释放的
NSData
。但是将调用留给
gpx=nil。当然,如果你不能复制这个问题,这很难测试。实际上我以前试过,并将代码部署给用户进行测试,但他们没有报告任何更改。谢谢我在MFMailComposeViewController和UIAppearance元素方面也有类似的问题。我从来没有找到答案,除了这是一个已知的问题。我将饶有兴趣地关注这个问题。我们没有使用UIAPI。我还决定向苹果公司提交一份技术支持请求。自动释放池可能会向您发布附件数据或文件名值。这些应该由控制器保留,但可能要等到出现ModalViewController和相关的viewDidLoad等。