2011-06-04 133 views
0

我有這段代碼MFMailComposer在模擬器和iPhone 4中正常工作,但它崩潰在3GS。什麼是解決它的原因和解決方法?MFMailComposer不能在iPhone 3GS

我用斷點檢查了它。 mailPicker未分配內存。

MFMailComposeViewController *mailPicker = [[MFMailComposeViewController alloc] init]; 
mailPicker.mailComposeDelegate = self; 

// Set the subject of email 
[mailPicker setSubject:@"Somebody got place in my sh*t list"]; 
NSString *emailBody = @"I just added somebody to my s**t list"; 

// This is not an HTML formatted email 
[mailPicker setMessageBody:emailBody isHTML:NO]; 

// Create NSData object as PNG image data from camera image 
NSData *data = UIImagePNGRepresentation([self captureScreen]); 

// Attach image data to the email 
// 'CameraImage.png' is the file name that will be attached to the email 
[mailPicker addAttachmentData:data mimeType:@"image/png" fileName:@"CameraImage"]; 

// Show email view 
[self presentModalViewController:mailPicker animated:YES]; 

// Release picker 

[mailPicker release]; 
+0

關於您在3GS上的崩潰 - 如果您可以提供一些關於崩潰和控制檯中的任何錯誤代碼/日誌的更多信息,那麼這將有所幫助。 – Luke 2011-06-04 19:46:02

回答

3

如果至少有一個電子郵件帳戶在設備上啓用,下面的調用應返回YES:

[MFMailComposeViewController canSendMail]

相反,如果所有的帳戶被禁用/刪除,否則返回NO。

+0

如果您的iPhone上沒有電子郵件帳戶,則不會觸碰它。簡單地說,如果iPhone上沒有電子郵件帳戶,它只會返回NO,並且沒有問題。 – Fattie 2013-10-24 12:16:42

相關問題