ios - 如何在 iOS 中分享 gif 动画图像

标签 ios

我对使用 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/

相关文章:

ios - iCarousel - 如何将焦点转移到左侧

ios - CoreData 中的递归获取

iphone - 仅当页码为零时隐藏上一个按钮,仅当页码为 20 时隐藏下一个按钮

ios - 通过segue将CollectionView的选定单元格索引发送到viewController

android - 在firebase,flutter中应该如何处理好友请求和邀请?

android - 如何在移动应用程序上隐藏来电者和来电号码

ios - 自定义呈现的 UIViewController 更改为全屏

ios - iOS 12 上的 ARKit 引用图像物理尺寸问题

c# - DialogViewController 打破 UINavigationController 路径

objective-c - NSLog 在设备上被忽略