要使用UIPasteBoard将gif粘贴到邮件窗口中
我想要显示一个gif,所以我做的是我分裂我的gif,并显示在一个animationUIImageView使用此链接。
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];
编辑只是注意到你自己问这两个类似的问题。
虽然您可以使用基于HTML的电子邮件 – 例如:
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init]; picker.mailComposeDelegate = self; NSString *emailBody = @"<p><b>Hello World</b></p>"; [picker setMessageBody:emailBody isHTML:YES];
您不能像插入HTML一样插入内嵌图像。 HTML电子邮件中的内嵌图像使用单独的MIME部分,这些部分是通过消息正文中的content-id元素引用的。 MFMailComposeViewController
不允许您控制消息的MIME结构,因此不会让您添加内联引用的内容部分。
将图像数据作为base64embedded到<img>
标签中有时会起作用 – 这取决于用于呈现它的电子邮件客户端和浏览器 – 但是它不具有广泛的可移植性。
FWIW,GIFanimation似乎可以在iOS 6的新分享表中使用电子邮件,如果用户select邮件,它将自动在电子邮件中填充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不支持animationGIF格式,我不认为有可能在邮件应用程序中复制/粘贴gif。 但是,您可以尝试使用MFMailComposeViewController
来附加gif文件(不是分割图像)并编写一个新的电子邮件。 如果您在非iOS设备上打开附件,则应该可以看到animationGIF。
HTH,
阿克沙伊
- 用CGImageDestinationFinalize创build一个大的GIF – 内存不足
- animationGIF不适用于iPhone
- 使用Angular在iPhone iOS 10上自动播放内联视频
- 我最喜欢的GIF应用功能:Vhoto(iOS)
- 使用SLRequestreplaceUIActivityViewController twitter发布的操作
- 在Swift中创build一个animationgif的问题
- 想从我的应用程序复制一个gif图像到应用程序内的邮件窗口。 我怎么做?
- 使用FLAnimatedImage的示例或演示SWIFT代码
- 如何在使用CGImageDestinationFinalize时避免malloc