我想显示一个 gif,所以我所做的就是拆分我的 gif 并使用此链接在 UIImageView 的动画中显示它。
http://iphonenativeapp.blogspot.com/2011/03/how-to-show-animation-in-iphoneipad-app.html
现在,我想让用户复制该 gif 并将其粘贴到邮件应用程序中。
如果我使用包含所有 gif 拆分图像的数组,那么 4-5 个图像会粘贴到邮件应用程序中。
请帮我贴一下gif。谢谢!
我想显示一个 gif,所以我所做的就是拆分我的 gif 并使用此链接在 UIImageView 的动画中显示它。
http://iphonenativeapp.blogspot.com/2011/03/how-to-show-animation-in-iphoneipad-app.html
现在,我想让用户复制该 gif 并将其粘贴到邮件应用程序中。
如果我使用包含所有 gif 拆分图像的数组,那么 4-5 个图像会粘贴到邮件应用程序中。
请帮我贴一下gif。谢谢!
将从类似问题中复制/粘贴我自己的答案。
NSString *gifPath = [[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent:@"volleyball.gif"];
NSData *gifData = [[NSData alloc] initWithContentsOfFile:gifPath];
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
[pasteboard setData:gifData forPasteboardType:@"com.compuserve.gif"];
[gifData release];
编辑刚刚注意到你自己问了这两个类似的问题。
Although you can use HTML based email -- for example:
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
NSString *emailBody = @"<p><b>Hello World</b></p>";
[picker setMessageBody:emailBody isHTML:YES];
You can't insert inline images as you would typically in HTML. Inline images in HTML email use separate MIME parts that are referenced via a content-id element from the body of the message. MFMailComposeViewController
doesn't give you control over the MIME structure of the message and thus doesn't let you add inline referenced content parts.
Embedding image data into <img>
tags as base64 will sometimes work -- it depends on the email client and browser used to render it -- but it's not broadly portable.
FWIW,动画 gif 似乎可以在 iOS 6 的新共享表中与电子邮件一起使用,如果用户选择邮件,它将自动在电子邮件中填充 gif:
NSString *gifPath = [[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent:@"volleyball.gif"];
NSData *gifData = [[NSData alloc] initWithContentsOfFile:gifPath];
NSArray *activityItems = [NSArray arrayWithObjects:@"Here is an awesome body for the email.",gifData,nil];
UIActivityViewController *activityController = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];
activityController.completionHandler = ^(NSString *activityType, BOOL completed){
// item was shared!
// you can check if it was email (or another type, like facebook or twitter) in the *activityType.
// completed is YES if they actually shared it, if they canceled, completed will be NO.
};
[navigationController presentViewController:activityController animated:YES completion:nil];
由于 iOS 不支持动画 GIF 格式,我认为无法在邮件应用程序中复制/粘贴 gif。但是,您可以尝试附加 gif 文件(而不是拆分图像)并使用MFMailComposeViewController
. 如果您在非 iOS 设备上打开附件,您应该能够看到动画 GIF。
高温下,
阿克谢