问题描述
对于使用UIActivityViewController共享动画的.gif图像,我一无所知.请帮助我提前解决此问题.
I am not getting any idea about sharing an animated .gif images using UIActivityViewController.please help me to resolve this.thanks in advance
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,尝试在ActivityItems数组中包含UIImage时遇到相同的问题.不能使用通用UIImage,也不能使用UIImage + animagedGIF类别的UIImage或FLAnimatedImage.
FWIW, I was having the same problem when trying to include a UIImage in the ActivityItems array. It will not work w/ a generic UIImage, nor a UIImage using the UIImage+animagedGIF category, nor FLAnimatedImage.
要解决此问题,至少在iOS8上,只需将gif作为NSData对象而不是UIImage添加到ActivityItems数组即可.
To resolve this problem, at least on iOS8, simply add the gif to the ActivityItems array as an NSData object rather than UIImage.
例如,假设正在从URL请求gif:
For example, assuming the gif is being requested from a URL:
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中共享gif动画图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!