【问题标题】:How do i attach image form ui view to email body如何将图像从 uiview 附加到电子邮件正文
【发布时间】:2012-05-01 01:03:15
【问题描述】:

我有一个小的 ui 视图,允许用户选择一个图片形式的相机胶卷,我想将它与我的电子邮件中的文本字段一起附加。

.h
 @property (strong, nonatomic) IBOutlet UIImageView *imageView;

 .m
  NSString *emailBody = [NSString stringWithFormat:@(textboxes and other outlets are      here)"%@"imageView.image];

通过电子邮件发送时,我得到了附加的文本字符串,但没有图像?有人能指出我正确的方向吗,谢谢

xcode 4.3

【问题讨论】:

    标签: string image ios5 uiview xcode4


    【解决方案1】:

    试试这个链接通过电子邮件发送图片

    http://iosdevelopertips.com/email/how-to-send-email-with-attachments-example-using-iphone-camera-to-email-a-photo.html

    如果这不是你想要的,你可能需要使用函数将图像转换为 nsdata

    NSData *data=UIImageJPEGRepresentation(image, 1.0);
    

    现在通过base64encoding将此数据转换为字符串,然后附加到字符串。

    【讨论】:

    • 感谢您的回复,电子邮件正文必须是 html,将图像与正文中的 html 文本一起附加会导致问题,我认为 base64 编码位超出了我的技能水平。还是谢谢
    • 在这种情况下,在您的代码中使用这两种分类方法...一种用于编码,另一种用于解码stackoverflow.com/questions/8804359/…
    猜你喜欢
    • 1970-01-01
    • 2010-10-06
    • 2016-12-29
    • 1970-01-01
    • 1970-01-01
    • 2019-01-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多