如何在iPhone邮件中添加gif到附件?

时间:2011-08-08 09:04:45

标签: ios email attachment gif

我这样添加.jpg:

UIImage *sentPic = self.image;
NSData *imageData = UIImageJPEGRepresentation(sentPic, 1);
[picker addAttachmentData:imageData mimeType:@"image/jpg" fileName:@"pic.jpg"];

我将其更改为“image / gif”。但它不能正常工作。 Th Gif只是邮件中的静止图像。

3 个答案:

答案 0 :(得分:1)

NSData *imageData = [[NSData alloc] initWithContentsOfFile:pathToGifFile];
[picker addAttachmentData:imageData mimeType:@"image/gif" fileName:@"pic.gif"];
[imageData release];

这会将其添加为附件,但我不确定这是否是您想要的,或者您想在消息中显示图像?

答案 1 :(得分:1)

您是否在电子邮件中尝试过这样的HTML代码:

NSString *emailBody = @"It is a gif email!";
emailBody = [EmailBody stringByAppendingString:@"<img src='http://xx.xx.pic.gif'>"];
[picker setMessageBody:emailBody isHTML:YES];

我没有测试过的代码,你可以尝试一下。告诉我们它是否有效。

答案 2 :(得分:0)

我刚试过这个。效果很好:

NSString *pathForGif = [[NSBundle mainBundle] pathForResource: @"<your file name>" ofType: @"gif"];

NSData *gifData = [NSData dataWithContentsOfFile: pathForGif];

[mailController addAttachmentData:gifData mimeType:@"image/gif" fileName:@"EmailGIF.gif"];
[self presentModalViewController:mailController animated:YES];