Flipboard / FLAnimatedImage

Performant animated GIF engine for iOS
MIT License
7.94k stars 1.22k forks source link

Loading GIFs in UICollectionView #220

Open iPhoneNoobDeveloper opened 5 years ago

iPhoneNoobDeveloper commented 5 years ago

I am loading GIFs in my horizontal UICollectionView. While scrolling UICollectionView, one cell's GIF exchange with another cell and then show's updated new GIF.

w99wen123dff commented 5 years ago

be careful of the cell reuse. if the gif is downloaded from web.

iPhoneNoobDeveloper commented 5 years ago

I have successfully implemented FLAnimatedImageView in UICollectionView using "<SDWebImage/FLAnimatedImageView+WebCache.h>". But it slows down the GIF speed in case of different 10 instances of GIF URLs.

collectionCell.flaAnimatedImageView.sd_predrawingEnabled = FALSE;
[collectionCell.flaAnimatedImageView sd_setImageWithURL:[NSURL URLWithString:imageUrlString] placeholderImage:[UIImage imageNamed:@"default_"] completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {

   CGDataProviderRef provider = CGImageGetDataProvider(image.CGImage);
    NSData* data = (id)CFBridgingRelease(CGDataProviderCopyData(provider));
    NSLog(@"File size is : %.2f MB",(float)data.length/1024.0f/1024.0f);

}];