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.
Permalink
Failed to load latest commit information.
Demo.xcodeproj
Docs/html
External
Images
Resources
Sources
.gitignore
Doxyfile
README.txt

README.txt

MHLazyTableImages

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.

REQUIREMENTS

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

INTEGRATION

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;
}
@end

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;
}

LICENSE

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. http://allseeing-i.com/ASIHTTPRequest/

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.
http://blog.ddg.com/?p=24

Portions of this source code are based on Apple's LazyTableImages sample and
are licensed under the terms of the Apple sample code license.
http://developer.apple.com/library/ios/#samplecode/LazyTableImages

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