top of page
  • Writer's pictureJennifer Eve Vega

Lazy Image Loading

Tutorial request from Senthil.P 1. Create a new Xcode Project, Single View Application template and add a tableview. (

2. Create a custom table view cell. (

3. Download SDWebImage latest framework here. (

Assuming everything\’s done, what\’s left for us to do is to include SDWebImage Library and use it in our project.

4. Right-click to your Project Navigator, Add Files to your project.

Add \”SDWebImage.framework\” from the one you downloaded from Step 3. Check \”Copy items into destination group\’s folder (if needed)\”

5. In our project\’s Build Phases, under Link Binary With Libraries, click the ( + ) button.

And add \”ImageIO.framework.\”

6. In our Project\’s Build Settings, search for \”Other Linker Flags,\” double-click the right area of the \”Other Linker Flags,\” click ( + ) button and input -ObjC

7. In the source files where you need to use the library, #import

8. Add an image file that will be used as our \”placeholder\” image. This image will be shown while the image from the URL has not yet finished loading.

9. Add entries to your array that holds the important information like the URL of the images you want to load.

– (void)viewDidLoad


    [super viewDidLoad];

// Do any additional setup after loading the view, typically from a nib.

items = [[NSMutableArray alloc] init];

    [items addObject:@\”\”];

    [items addObject:@\”\”];

    [items addObject:@\”\”];

    [items addObject:@\”\”];

    [items addObject:@\”\”];


10. Edit our tableview\’s cellForRowAtIndexPath…

– (UITableViewCell *)tableView😦UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

static NSString *CellIdentifier = @\”MyImageCell\”;

ImageCell *cell = (ImageCell *) [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

if (cell == nil) {

NSArray* topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@\”ImageCell\” owner:self options:nil];

for (id currentObject in topLevelObjects) {

if ([currentObject isKindOfClass:[UITableViewCell class]]) {

                cell = (ImageCell *)currentObject;





// Here we use the new provided setImageWithURL: method to load the web image

    [cell.imageView setImageWithURL:[NSURL URLWithString:[items objectAtIndex:indexPath.row]]  placeholderImage:[UIImage imageNamed:@\”Hisoka.jpg\”]];

    cell.imageSource.text = [items objectAtIndex:indexPath.row];

return cell;


11. Hit Run!

There are still many ways to use SDWebImage Library, just check their API Documentation and other ways to use it in: (

Download Project here.

#SDWebImage #imagecache #imageloading #LoadingImage #lazyimageloading #LoadingImageiOS #Imagecaching #lazyimageloadingiOS #imageloadingiOS

6 views0 comments

Recent Posts

See All

Hi Everyone! It has been a very long while since I last posted in this blog. This time, I will be making a tutorial in using blocks when we are accessing our API or web services. Disclaimer: I am also

Post: Blog2 Post
bottom of page