2011-06-04 70 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