gpt4 book ai didi

ios7 - 应用程序使用 MFMailComposeViewController 崩溃

转载 作者:行者123 更新时间:2023-12-03 16:22:36 24 4
gpt4 key购买 nike

我在 iOS 7 上遇到了这个崩溃,

Assertion failed: (result == KERN_SUCCESS), function + [XPCMachSendRight wrapSendRight:], file /SourceCache/XPCObjects/XPCObjects-46/XPCMachSendRight.m, line27.

导致此崩溃的步骤是,
  • 开业MFMailComposeViewController
  • 按主页键
  • 应用程序崩溃。

  • 这是崩溃报告,
    Thread 0 Crashed:
    0 libsystem_kernel.dylib 0x393bf1fc 0x393ac000 + 78332
    1 libsystem_pthread.dylib 0x39426a4f 0x39423000 + 14927
    2 libsystem_c.dylib 0x39370083 0x39326000 + 303235
    3 libsystem_c.dylib 0x39370035 0x39326000 + 303157
    4 libsystem_c.dylib 0x3934fc67 0x39326000 + 171111
    5 XPCObjects 0x375a7905 0x375a2000 + 22789
    6 UIKit 0x317b41f9 0x3128d000 + 5403129
    7 UIKit 0x31529d45 0x3128d000 + 2739525
    8 QuartzCore 0x30f54af9 0x30f13000 + 269049
    9 QuartzCore 0x30f1b077 0x30f13000 + 32887
    10 QuartzCore 0x30f1ae1b 0x30f13000 + 32283
    11 UIKit 0x31318deb 0x3128d000 + 572907
    12 UIKit 0x31318d53 0x3128d000 + 572755
    13 CoreFoundation 0x2eaddf6f 0x2ea3e000 + 655215
    14 CoreFoundation 0x2eadb8fb 0x2ea3e000 + 645371
    15 CoreFoundation 0x2eadbbb5 0x2ea3e000 + 646069
    16 CoreFoundation 0x2ea4653d 0x2ea3e000 + 34109
    17 CoreFoundation 0x2ea4631f 0x2ea3e000 + 33567
    18 GraphicsServices 0x337762e7 0x3376f000 + 29415
    19 UIKit 0x312fd1e1 0x3128d000 + 459233
    20 MYAPP 0x0002d5c9 main (main.mm:18)
    21 MYAPP 0x0002d524 start + 36

    我发现这里提到的类似问题: app get crashed while navigating to RootViewController from Message popup

    崩溃很少发生。不知道是什么 [XPCMachSendRight wrapSendRight:]这是以及如何防止它使我的应用程序崩溃?

    最佳答案

    使用前MFMailComposeViewController类,您必须始终检查当前设备是否配置为使用 canSendMail 发送电子邮件。方法。如果用户的设备未设置用于发送电子邮件,您可以通知用户或简单地禁用应用程序中的电子邮件发送功能。如果 canSendMail方法返回 .

    使用此代码....

    if ([MFMailComposeViewController canSendMail])
    {
    MFMailComposeViewController *mailer = [[MFMailComposeViewController alloc] init];
    mailer.mailComposeDelegate = self;
    [mailer setSubject:@"A Message from Bloomingkids"];
    NSArray *toRecipients = [NSArray arrayWithObjects:@"support@bloomingkids.com", nil];
    [mailer setToRecipients:toRecipients];
    UIImage *myImage = [UIImage imageNamed:@"bloomingKidsLogo.png"];
    NSData *imageData = UIImagePNGRepresentation(myImage);
    [mailer addAttachmentData:imageData mimeType:@"image/png" fileName:@"Images"];
    NSString *emailBody = @"Have you seen the Bloomingkids web site?";
    [mailer setMessageBody:emailBody isHTML:NO];
    [self presentViewController:mailer animated:YES completion:nil];
    }
    else
    {
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Failure"
    message:@"Your device doesn't support the composer sheet"
    delegate:nil
    cancelButtonTitle:@"OK"
    otherButtonTitles: nil];
    [alert show];
    }

    首先在您的设备中添加任何电子邮件帐户意味着设置一个电子邮件帐户...

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

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