ios - 当InApp mail命令被调用时,应用程序崩溃
当我通过UIActionSheet按钮粘贴消息撰写表时,我收到以下错误。对不起,这些对我来说并不意味着什么 - 还在学习: - )
When I cll the Message Compose sheet via a UIActionSheet button I get the following error. Sorry these don't mean much to me yet - still learning:-)
有人可以帮忙吗?
这些是出现问题的根源。
These are the sources of problems that come up.
这是在日志中:
2012-06 -16 19:10:43.437 Multi Web [2665:4013] XPCProxy收到不好的消息:target没有提供bodyFinishedDrawing的方法签名
2012-06-16 19:10:43.489 Multi Web [2665:907] _serviceViewControllerReady:错误:错误域= XPCObjectsErrorDomain代码= 3操作无法完成(XPCObjectsErrorDomain错误3。)
2012-06-16 19:10:43.437 Multi Web[2665:4013] XPCProxy received bad message: target did not supply method signature for bodyFinishedDrawing 2012-06-16 19:10:43.489 Multi Web[2665:907] _serviceViewControllerReady:error: Error Domain=XPCObjectsErrorDomain Code=3 "The operation couldn’t be completed. (XPCObjectsErrorDomain error 3.)"
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];
}
正确的答案是删除
The correct answer is to remove the
[self dismissModalViewControllerAnimated:YES]
就在PresentModalViewController方法之后。
just after the presentModalViewController method.
你正在崩溃,模态视图控制器在提交后不久,并尝试在回调代理中再次将其解除(已被释放)。
You are crashing because, you dismiss the modal view controller soon after it is presented and try to dismiss it again (which is deallocated already) in the callback delegate.
您可以在我的帖子中阅读有关如何发送应用电子邮件。
You can read about how to send an in app email here on my post.
http://blog.mugunthkumar.com/coding/iphone-tutorial-in-app-电子邮件/