user1728987
user1728987

Reputation: 329

How to use SDWebImage in my project

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

Answers (2)

user6503043
user6503043

Reputation:

Use this code

[YOUR_CELL_NAME.YOUR_IMAGE_NAME setImageWithURL:[NSURL URLWithString:@"IMAGE URL"] placeholderImage:[UIImage imageNamed:@"PLACEHOLDER IMAGE NAME"]];

Upvotes: 1

Raza.najam
Raza.najam

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

Related Questions