【发布时间】:2019-04-19 20:30:22
【问题描述】:
在我的 iOS 应用程序中,我想在我的tableViewCell 中显示 Gif 图像。通过SDWebImage下载此GIF图片,并使用FLAnimatedImageView显示此图片。
但是现在我有一个问题,SDWebImage 返回一个图片,但是FLAnimatedImageView 想要一个NSData。
如何将gif的图片转换为NSData?
请原谅我糟糕的英语。
[[SDWebImageManager sharedManager] downloadImageWithURL:url options:0 progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
if (image.images.count > 0)//gif
{
// how to get the data
FLAnimatedImage *animatedImage = [FLAnimatedImage animatedImageWithGIFData:data];
_chatGIFImage.animatedImage = animatedImage1;
}
}];
【问题讨论】:
-
使用SDwebimage lib可以直接使用gif图片
-
我发现“UIImage+GIF.h”有一个方法:“+ (UIImage *)sd_animatedGIFWithData:(NSData *)data;”如何获得反向方法?将 gif 图像转换为 NSData。
-
@Jigar Tarsariya 我已经用SDwebimage显示gif图片了,但是内存泄漏很大,两张2M的gif图片可以在线带来200M的内存泄漏,应用程序很容易崩溃,我想我的幸福生活不会再长一点,老板会惩罚我的。/(ㄒoㄒ)/~~
-
Ohhhk...然后您必须找到将您的 gif 图像转换为 NSData 的方法.. :)
-
@Jigar Tarsariya 是的,我被折磨了一天。
标签: ios nsdata sdwebimage