Tips for Lazy Loading of Images in IOS

Tips for Lazy Loading of Images in IOS

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. (https://github.com/rs/SDWebImage/wiki/Download-Complied-Framework)

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 <SDWebImage/UIImageView+WebCache.h>

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.

10. Edit our tableview’s cellForRowAtIndexPath…

11. Hit Run!