UIImageView.Image 使用 MonoTouch 发送邮件附件

发布于 2025-01-02 07:58:56 字数 269 浏览 0 评论 0原文

我是 MonoTouch 新手,我正在尝试发送一封电子邮件,其中包含图像作为附件,用户将从相机中驯服或从图库中选择该图像。

我已经创建了程序并且它运行正确(我有一个 imageview 控制器,它将图像从 uiimagepicker 加载到 imageview。然后我调用 MFMailComposeViewController ,但我不知道如何将图像从 imageview 传递到 < 我想首先我必须将 imageview 中的图像保存为文件,但我不知道该怎么做,

也找不到它的文档。

I am new to MonoTouch and I am trying to send an email with an image as attachment that a user will tame from camera or pick from gallery.

I have created the program and it runs correctly (I have an imageview controller which loads an image from uiimagepicker to imageview. Then I call MFMailComposeViewController but I don't know how to pass the image from imageview to addAttachmentdata method.

I suppose first I have to save the image from imageview as a file but I don't know how to do it and I can't find documentation for it.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

半世蒼涼 2025-01-09 07:58:56

首先,您需要将 UIImage 转换为 NSData,例如使用 AsPNGAsJPG,然后使用右侧的 <图像的strong>MIME类型。下面是一个示例:

MFMailComposeViewController email = new MFMailComposeViewController ();
// any UIImage will do
UIImage img = UIImage.FromFile (".../anyimage.png");
email.AddAttachmentData (img.AsPNG (), "image/png", "image.png");
email.SetSubject ("Photo from my iPhone");
email.SetMessageBody ("Here's the attachment!", false);
controller.PresentModalViewController (email, false);

注意“image.png”是一个建议的 提供给收件人电子邮件软件的文件名(即它不是您设备中的本地文件,并且不需要与现有的任何文件匹配)。

First you need to turn the UIImage into an NSData, e.g. using AsPNG or AsJPG, then use the right MIME type for the image. Here's an example:

MFMailComposeViewController email = new MFMailComposeViewController ();
// any UIImage will do
UIImage img = UIImage.FromFile (".../anyimage.png");
email.AddAttachmentData (img.AsPNG (), "image/png", "image.png");
email.SetSubject ("Photo from my iPhone");
email.SetMessageBody ("Here's the attachment!", false);
controller.PresentModalViewController (email, false);

Note: the "image.png" is a suggested file name given to the recipient email software (i.e. it's not a local file in your device and does not need to match anything that exists).

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