2012-06-16 40 views
3

當我通過UIActionSheet按鈕完成Message Compose表單時,出現以下錯誤。對不起,這些對我來說意義不大 - 仍然在學習:-)ios - 當InApp郵件命令被調用時,應用程序崩潰

請問誰能幫忙?

這是問題出現的根源。

list that appears when the app crashes.

Green Bar error

這是在日誌中:

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]; 

}

+0

有些代碼對我們很有幫助。 – Akshay

+0

嗨,我添加了整個方法,我希望它的幫助 –

+1

//刪除郵件視圖 [self dismissModalViewControllerAnimated:YES]; 刪除此行,然後再試一次,因爲郵件視圖仍然沒有加載,所以你正在解僱哪個模態視圖 – Sumanth

回答

1

正確答案是在presentModalViewController方法後面刪除

[self dismissModalViewControllerAnimated:YES] 

您正在崩潰,因爲您在呈現模型視圖控制器後立即關閉模型視圖控制器,並嘗試在回調委託中再次解除模式視圖控制器(已解除分配)。

您可以在我的文章中閱讀關於如何發送應用內電子郵件。

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

相關問題