将图像添加到邮件时出错 - MFMailComposeViewController [英] Error when adding an image to an Mail - MFMailComposeViewController

查看:36
本文介绍了将图像添加到邮件时出错 - MFMailComposeViewController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 MFMailComposeViewController 发送已添加到我的项目中的图像.

I'm trying to send an Image, which I have added to my Project, using the MFMailComposeViewController.

我在模拟器中尝试了这个,它工作正常,我也可以在文本字段中看到图像,但是当我尝试发送邮件时,我在控制台上收到以下错误:

I tried this in the simulator and it works fine, I can also see the Image in the Textfield, but when I'm trying to send the Mail, I get the following error on console:

2 月 10 日 16:22:02 markuss-macbook-pro.speedport.ip RMC Konus[1825]:CGImageCreate:图像大小无效:0 x 0.

Feb 10 16:22:02 markuss-macbook-pro.speedport.ip RMC Konus[1825] : CGImageCreate: invalid image size: 0 x 0.

我的代码:

//Get the Image
UIImage *image = [UIImage imageNamed:@"image.png"];

NSData *imageData = UIImagePNGRepresentation(image);

//Create the Mail View
MFMailComposeViewController *mailCV = [[MFMailComposeViewController alloc] init];

[mailCV setMailComposeDelegate:self];



[mailCV addAttachmentData:imageData mimeType:@"image/png" fileName:@"exGraphic.png"];

//Show the View Controller
[self presentViewController:mailCV animated:YES completion:nil];

推荐答案

问题只出现在模拟器中.我在许多不同的设备上检查了这些代码,它仍然可以正常工作.所以我会说,这是模拟器的问题......

The problems only appears in the simulator. I check these code on many different devices and it still works without problems. So I would say, it is a problem of the simulator ...

这篇关于将图像添加到邮件时出错 - MFMailComposeViewController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆