Allows you to efficiently, and easily, download images for UITableViews with many rows
Objective-C JavaScript Other
Switch branches/tags
Nothing to show
Pull request Compare This branch is 3 commits ahead, 5 commits behind hollance:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



This is a rewrite of Apple's LazyTableImages sample project, which allows for
efficient downloading of images in a table view with many rows. The lazy image
loading has been refactored into a class of its own, MHLazyTableImages, which
makes it very easy to use. The class MHImageCache is used to cache the images.
The code has also been changed to use blocks and ASIHTTPRequest.


- ASIHTTPRequest
- Reachability
- MobileCoreServices.framework
- CFNetwork.framework
- libz.dylib (zlib)
- SystemConfiguration.framework


Add MHLazyTableImages.*, MHImageCache.* and the requirements to the target.

In the table view controller add an MHLazyTableImages instance. 
You should create it and set the delegate somewhere in the initialization code:

@interface RootViewController : UITableViewController <MHLazyTableImagesDelegate>
  MHLazyTableImages* lazyImages;

Implement the delegate methods:

- (void)scrollViewDidEndDragging:(UIScrollView*)scrollView willDecelerate:(BOOL)decelerate
  [lazyImages scrollViewDidEndDragging:scrollView willDecelerate:decelerate];

- (void)scrollViewDidEndDecelerating:(UIScrollView*)scrollView
	[lazyImages scrollViewDidEndDecelerating:scrollView];

- (NSURL*)lazyImageURLForIndexPath:(NSIndexPath*)indexPath
    return /* NSURL instance for indexPath */

- (UIImage*)postProcessLazyImage:(UIImage*)image forIndexPath:(NSIndexPath*)indexPath
    return /* original or modified UIImage instance for indexPath */

Add the image to the cell:

- (UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath
[lazyImages addLazyImageForCell:cell withIndexPath:indexPath];
return cell;


The MHLazyTableImages and MHImageCache source code is copyright 2011 Matthijs
Hollemans and is licensed under the terms of the MIT license.

The ASIHTTPRequest source code is copyright Ben Copsey and is licensed under 
the terms of the BSD license.

The Reachability source code is copyright Apple and Andrew W. Donoho and is
licensed under the terms of the BSD and Apple sample code licenses.

Portions of this source code are based on Apple's LazyTableImages sample and
are licensed under the terms of the Apple sample code license.

Any source files without a license header are considered to be public domain.