MFMailComposer 在 iPhone 3GS 中无法工作
我的 MFMailComposer
代码在模拟器和 iPhone 4 中工作正常,但它在 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];
I have this piece of code for MFMailComposer
working fine in the simulator and iPhone 4, but it crashes on 3GS. What is the reason and what is the way to resolve it?
I checked it with breakpoints. mailPicker
is not allocated with memory.
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];
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果设备上至少启用了一个电子邮件帐户,则以下调用应返回 YES:
[MFMailComposeViewController canSendMail]
相反,如果所有帐户均已禁用/删除,则它将返回 NO。
If at least one email account is enabled on the device, the following call should return YES:
[MFMailComposeViewController canSendMail]
Conversely, if all accounts are disabled/removed, it will return NO.