在我的iOS應用程序中,我想在我的tableViewCell
中顯示一個Gif圖像。通過SDWebImage
下載這張Gif圖像,並使用FLAnimatedImageView
顯示此圖像。如何將gif圖片的圖像轉換爲iOS的NSData?
但現在我有一個問題,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;
}
}];
您可以直接使用gif圖像通過使用SDwebimage lib –
我發現「UIImage + GIF.h」有一個方法: 「+(UIImage *)sd_animatedGIFWithData:(NSData *)data;」 如何得到一個反轉的方法?將gif圖像轉換爲NSData。 – Maker
@Jigar Tarsariya我已經使用SDwebimage來顯示gif圖片,但它有巨大的內存泄漏,兩個2M gif圖片可能會在網上帶來200M內存泄漏,應用程序很容易崩潰,我認爲我的幸福生活不會再長,我的老闆會懲罰我./(ㄒoㄒ)/ ~~ – Maker