Declared in UIImageView+WebCache.h
UIImageView+WebCache.m

Overview

  • Integrates SDWebImage async downloading and caching of remote images with UIImageView. *
  • Usage with a UITableViewCell sub-class: *
  • @code

import <SDWebImage/UIImageView+WebCache.h>

  • (UITableViewCell )tableView:(UITableView )tableView cellForRowAtIndexPath:(NSIndexPath )indexPath { static NSString MyIdentifier = @“MyIdentifier”;

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];

    if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MyIdentifier] autorelease]; }

    // Here we use the provided setImageWithURL: method to load the web image // Ensure you use a placeholder image otherwise cells will be initialized with no image [cell.imageView setImageWithURL:[NSURL URLWithString:@“http://example.com/image.jpg”] placeholderImage:[UIImage imageNamed:@“placeholder”]];

    cell.textLabel.text = @“My Text”; return cell; }

  • @endcode

Instance Methods

cancelCurrentImageLoad

Cancel the current download

- (void)cancelCurrentImageLoad

Declared In

UIImageView+WebCache.h

setAnimationImagesWithURLs:

Download an array of images and starts them in an animation loop

- (void)setAnimationImagesWithURLs:(NSArray *)arrayOfURLs

Parameters

arrayOfURLs

An array of NSURL

Declared In

UIImageView+WebCache.h

setImageWithURL:

Set the imageView image with an url.

- (void)setImageWithURL:(NSURL *)url

Parameters

url

The url for the image.

Discussion

The downloand is asynchronous and cached.

Declared In

UIImageView+WebCache.h

setImageWithURL:completed:

Set the imageView image with an url.

- (void)setImageWithURL:(NSURL *)url completed:(SDWebImageCompletedBlock)completedBlock

Parameters

url

The url for the image.

completedBlock

A block called when operation has been completed. This block as no return value and takes the requested UIImage as first parameter. In case of error the image parameter is nil and the second parameter may contain an NSError. The third parameter is a Boolean indicating if the image was retrived from the local cache of from the network.

Discussion

The downloand is asynchronous and cached.

Declared In

UIImageView+WebCache.h

setImageWithURL:placeholderImage:

Set the imageView image with an url and a placeholder.

- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder

Parameters

url

The url for the image.

placeholder

The image to be set initially, until the image request finishes.

Discussion

The downloand is asynchronous and cached.

Declared In

UIImageView+WebCache.h

setImageWithURL:placeholderImage:completed:

Set the imageView image with an url, placeholder.

- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletedBlock)completedBlock

Parameters

url

The url for the image.

placeholder

The image to be set initially, until the image request finishes.

completedBlock

A block called when operation has been completed. This block as no return value and takes the requested UIImage as first parameter. In case of error the image parameter is nil and the second parameter may contain an NSError. The third parameter is a Boolean indicating if the image was retrived from the local cache of from the network.

Discussion

The downloand is asynchronous and cached.

Declared In

UIImageView+WebCache.h

setImageWithURL:placeholderImage:options:

Set the imageView image with an url, placeholder and custom options.

- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options

Parameters

url

The url for the image.

placeholder

The image to be set initially, until the image request finishes.

options

The options to use when downloading the image. @see SDWebImageOptions for the possible values.

Discussion

The downloand is asynchronous and cached.

Declared In

UIImageView+WebCache.h

setImageWithURL:placeholderImage:options:completed:

Set the imageView image with an url, placeholder and custom options.

- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock

Parameters

url

The url for the image.

placeholder

The image to be set initially, until the image request finishes.

options

The options to use when downloading the image. @see SDWebImageOptions for the possible values.

completedBlock

A block called when operation has been completed. This block as no return value and takes the requested UIImage as first parameter. In case of error the image parameter is nil and the second parameter may contain an NSError. The third parameter is a Boolean indicating if the image was retrived from the local cache of from the network.

Discussion

The downloand is asynchronous and cached.

Declared In

UIImageView+WebCache.h

setImageWithURL:placeholderImage:options:progress:completed:

Set the imageView image with an url, placeholder and custom options.

- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletedBlock)completedBlock

Parameters

url

The url for the image.

placeholder

The image to be set initially, until the image request finishes.

options

The options to use when downloading the image. @see SDWebImageOptions for the possible values.

progressBlock

A block called while image is downloading

completedBlock

A block called when operation has been completed. This block as no return value and takes the requested UIImage as first parameter. In case of error the image parameter is nil and the second parameter may contain an NSError. The third parameter is a Boolean indicating if the image was retrived from the local cache of from the network.

Discussion

The downloand is asynchronous and cached.

Declared In

UIImageView+WebCache.h