为什么MFMailComposeViewController在iOS 8.3上崩溃?

时间:2015-05-12 20:41:35

标签: ios mfmailcomposeviewcontroller

我最近提交了一个供审核的应用,在启动电子邮件链接时崩溃了。我尝试了多次使用多个设备,并且无法重新创建它,但没有iPad Air 2.但是,看起来好像可能与未包含[MFMailComposeViewController canSendMail]的检查有关,尽管我不确定这是否会导致崩溃。任何人都可以提供一些有关崩溃原因的见解吗?谢谢!

在审核期间,当我们执行以下操作时,您的应用程序在运行iOS 8.3的iPad Air 2上崩溃: 1.按“提供反馈”按钮

以下是错误日志:

Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Triggered by Thread:  0

Last Exception Backtrace:
(0x1839bc2d8 0x1950dc0e4 0x18871ea98 0x188720934 0x1884ea158 0x1000bc128 0x188431404 0x18841a4e0 0x188430da0 0x188430a2c 0x188429f68 0x1883fd18c 0x18869e324 0x1883fb6a0 0x183974240 0x1839734e4 0x183971594 0x18389d2d4 0x18cf8b6fc 0x188462fac 0x1000bc6f0 0x19575aa08)

Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   libsystem_kernel.dylib          0x0000000195873270 0x195858000 + 111216
1   libsystem_pthread.dylib         0x000000019591116c 0x19590c000 + 20844
2   libsystem_c.dylib               0x00000001957eab14 0x195788000 + 404244
3   libc++abi.dylib                 0x00000001948a9414 0x1948a8000 + 5140
4   libc++abi.dylib                 0x00000001948c8b88 0x1948a8000 + 134024
5   libobjc.A.dylib                 0x00000001950dc3bc 0x1950d4000 + 33724
6   libc++abi.dylib                 0x00000001948c5bb0 0x1948a8000 + 121776
7   libc++abi.dylib                 0x00000001948c5738 0x1948a8000 + 120632
8   libobjc.A.dylib                 0x00000001950dc290 0x1950d4000 + 33424
9   CoreFoundation                  0x000000018389d380 0x183894000 + 37760
10  GraphicsServices                0x000000018cf8b6f8 0x18cf80000 + 46840
11  UIKit                           0x0000000188462fa8 0x1883ec000 + 487336
12  b2bGatewayWebview               0x00000001000bc6ec 0x100098000 + 149228
13  libdyld.dylib                   0x000000019575aa04 0x195758000 + 10756

代码:

- (IBAction)touchRequestEnhancement:(id)sender {
    // Email Subject
    NSString *emailTitle = @"iOS App Feedback";
    // Email Content
    NSString *messageBody = @"Enter message here";
    // To address
    NSArray *toRecipents = [NSArray arrayWithObject:@"xxxx@xxxx.com"];

    MFMailComposeViewController *mc = [[MFMailComposeViewController alloc] init];
    mc.mailComposeDelegate = self;
    [mc setSubject:emailTitle];
    [mc setMessageBody:messageBody isHTML:NO];
    [mc setToRecipients:toRecipents];

    // Present mail view controller on screen
    [self presentViewController:mc animated:YES completion:NULL];
}


- (void) mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error
{
    switch (result)
    {
        case MFMailComposeResultCancelled:
            NSLog(@"Mail cancelled");
            break;
        case MFMailComposeResultSaved:
            NSLog(@"Mail saved");
            break;
        case MFMailComposeResultSent:
            NSLog(@"Mail sent");
            break;
        case MFMailComposeResultFailed:
            NSLog(@"Mail sent failure: %@", [error localizedDescription]);
            break;
        default:
            break;
    }

    // Close the Mail Interface
    [self dismissViewControllerAnimated:YES completion:NULL];
}

1 个答案:

答案 0 :(得分:1)

在iPhone上书写,请原谅我的简洁。保留对邮件控制器的强引用,直到最终委托回调。

相关问题