iOS应用在调用InApp邮件命令时崩溃。

3
当我通过UIActionSheet按钮调用消息撰写表时,会出现以下错误。对不起,这些对我来说意义不大-还在学习中:-)
请问有人可以帮忙吗?
这些是出现的问题来源。
这是日志中的内容:
2012-06-16 19:10:43.437 Multi Web[2665:4013] XPCProxy收到了错误消息:目标未为bodyFinishedDrawing提供方法签名 2012-06-16 19:10:43.489 Multi Web[2665:907] _serviceViewControllerReady:error: 错误领域=XPCObjectsErrorDomain Code=3 "无法完成操作。(XPCObjectsErrorDomain错误3。)"
欢呼 Jeff
        if ([MFMailComposeViewController canSendMail])
    {
        MFMailComposeViewController *mailer = [[MFMailComposeViewController alloc] init];
        mailer.mailComposeDelegate = self;

        NSString *subject = [[NSString alloc] initWithFormat:@"Multi Web - Sending %@.txt", _documentFile];

        [mailer setSubject:subject];

        // Attach an image to the email
        NSString *pathFile01 = [NSString stringWithFormat:_documentTXTPath];
        NSURL *pdfURLFile01 =  [NSURL URLWithString:pathFile01];
        NSData *pdfDataFile01 = [NSData dataWithContentsOfURL:pdfURLFile01];
        NSString *fileName = [[NSString alloc] initWithFormat:@"%@.txt", _documentFile];
        [mailer addAttachmentData:pdfDataFile01 mimeType:@"application/txt" fileName:fileName];

        NSString *emailBody = 
       @"Hi,<br><br>Please find attached the note exported from Multi Web.<br/><br/>Thanks you for using the app.<br/><br/>Kind Regards,<br/>Multi Web Team.";


        [mailer setMessageBody:emailBody isHTML:YES];

        [self presentModalViewController:mailer animated:YES];
    }

    // Remove the mail view
    [self dismissModalViewControllerAnimated:YES];



- (void)mailComposeController:(MFMailComposeViewController*)controller  didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
 {
 switch (result)
 {
    case MFMailComposeResultCancelled:
        NSLog(@"Mail cancelled: you cancelled the operation and no email message was queued.");
        break;
    case MFMailComposeResultSaved:
        NSLog(@"Mail saved: you saved the email message in the drafts folder.");
        break;
    case MFMailComposeResultSent:
        NSLog(@"Mail send: the email message is queued in the outbox. It is ready to send.");
        break;
    case MFMailComposeResultFailed:
        NSLog(@"Mail failed: the email message was not saved or queued, possibly due to an error.");
        break;
    default:
        NSLog(@"Mail not sent.");
        break;
}

// Remove the mail view
[self dismissModalViewControllerAnimated:YES];

}


一些代码对我们会很有帮助。 - Akshay
嗨,我添加了整个方法,希望它有所帮助。 - jwknz
1
// 删除邮件视图 [self dismissModalViewControllerAnimated:YES]; 删除此行代码并重试,因为邮件视图仍未加载,因此您正在关闭哪个模态视图。 - Sumanth
@Sumanth 谢谢,这个方法很管用 :-) 有趣的是,在另一个项目中留下那行代码也能工作 - 唯一的区别是这次我通过 actionSheet 调用它。奇怪 :-) - jwknz
1个回答

1
正确答案是删除


[self dismissModalViewControllerAnimated:YES] 

就在presentModalViewController方法之后。

你的应用程序崩溃了,因为你在它被呈现后很快就将模态视图控制器解除,并在回调委托中尝试再次解除它(它已经被释放了)。

你可以在我的帖子中阅读有关如何发送应用内电子邮件的信息。

http://blog.mugunthkumar.com/coding/iphone-tutorial-in-app-email/


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接