我对使用 UIActivityViewController 共享动画 .gif 图像一无所知。请帮我解决这个问题。提前致谢
see this image .i am displaying this type of images and to share these images I am using uiactivity view but it is not animating .it's just displaying image
if(imgFrameCount==1)
{
imgFrameCount++;
NSURL *url1=[[NSBundle mainBundle]URLForResource:@"animated2" withExtension:@"gif"];
self.firstImage=[UIImage animatedImageWithAnimatedGIFData:[NSData dataWithContentsOfURL:url1]];
self.frameImage.image = self.firstImage;
}
else if (imgFrameCount==2)
{
imgFrameCount++;
NSURL *url2=[[NSBundle mainBundle]URLForResource:@"animated3" withExtension:@"gif"];
self.firstImage=[UIImage animatedImageWithAnimatedGIFData:[NSData dataWithContentsOfURL:url2]];
self.frameImage.image = self.firstImage;
}
最佳答案
FWIW,我在尝试将 UIImage 包含在 ActivityItems 数组中时遇到了同样的问题。它不适用于通用 UIImage,也不适用于使用 UIImage+animagedGIF 类别的 UIImage,也不适用于 FLAnimatedImage。
要解决此问题,至少在 iOS8 上,只需将 gif 作为 NSData 对象而不是 UIImage 添加到 ActivityItems 数组。
例如,假设从 URL 请求 gif:
NSURL *imagePath = [NSURL URLWithString:@"http://i.imgur.com/X4oonnm.gif"];
NSData *animatedGif = [NSData dataWithContentsOfURL:imagePath];
NSArray *sharingItems = [NSArray arrayWithObjects: animatedGif, nil];
UIActivityViewController *activityController = [[UIActivityViewController alloc] initWithActivityItems:sharingItems applicationActivities:nil];
关于ios - 如何在 iOS 中分享 gif 动画图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26623931/