Reputation: 329
Iam using collectionview to load image.These images are loaded from url in background thread. Hence the scrolling is not smooth.The images in url get expired after seconds hence i want to update the image with new image.How can i use the SDWebImage to load image and make scrolling smooth? Can anyone please help me to solve this.
Upvotes: 3
Views: 636
Reputation:
Use this code
[YOUR_CELL_NAME.YOUR_IMAGE_NAME setImageWithURL:[NSURL URLWithString:@"IMAGE URL"] placeholderImage:[UIImage imageNamed:@"PLACEHOLDER IMAGE NAME"]];
Upvotes: 1
Reputation: 769
You need to integrate the sdwebimage classes in your code. After that make a import.
Download sdwebimage from here
#import "UIImageView+WebCache.h"
and in your collectionview method write following lines to download image in backend thread.
[YOUR_CELL_NAME.YOUR_IMAGE_NAME setImageWithURL:[NSURL URLWithString:@"IMAGE URL"] placeholderImage:[UIImage imageNamed:@"PLACEHOLDER IMAGE NAME"]];
Upvotes: 0