• Home
  • Code
  • Scroll Lazy Image Load for iOS
 
28
0
0

Scroll Lazy Image Load for iOS

Max JohnsonviaBinpress
May 07, 2012
Package Details

Available on: Binpress

Costs

Free

A customizable UIScrollView for lazy loading multiple images. Useful for quickly loading views that contain images loaded from the web. Very simple to add to your application and style to your application look and feel.

Functionality

When the application loads, activity indicators are shown where images are being downloaded. Once the images are downloaded they will replace the loading indicators.

Clicking on an image will load that image on top of UIScrollView.

Usage

Create a controller that implements ScrollLazyloadViewController.

In addition, the following classes must be implemented:

  1. Model class named ClsImgs
  2. UIView class named LazyloadView
  3. NSObject class named ImageDownloader

Implement ImageLazyLoadDelegate and create the properties included in ScrollLazyloadViewController.h :

@interface ScrollLazyloadViewController : UIViewController <ImageLazyLoadDelegate>

Modify objClsImgs.strURL in -(void)loadScrollImages to point to your images.

-(void)loadScrollImages function will add all objects of ClsImgs to Array and then It will set UIScrollView using -(void)setImageScrollView function.

In -(void)setImageScrollView, you can edit width and height of LazyLoadView using xPos += 68; and [scrollView setContentSize:CGSizeMake(xPos, 62)]; where 68 and 62 is width and height respectively.

For this you should have to change in your LazyLoadView.xib file accordingly in width or height.

ImageDownloader.h/m are used to download image using NSURLConnection. where we are passing objClsImgs.strURL for NSURLRequest in NSURLConnection.

- (void)loadImages checks for each image, if it is downloaded or pending.

If Images are not downloaded then It will call - (void)startIconDownload:(ClsImgs *)pClsImages forImgTag:(NSInteger)pImgTag.

After images are downloaded, - (void)appImageDidLoad:(NSInteger)pImgTag is called - use that for post load operations.

Discussion

-