MFMailComposer 在 iPhone 3GS 中无法工作

发布于 2024-11-12 05:36:42 字数 1044 浏览 5 评论 0原文

我的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

爺獨霸怡葒院 2024-11-19 05:36:42

如果设备上至少启用了一个电子邮件帐户,则以下调用应返回 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文