Conforms to SDWebImageManagerDelegate
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:

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

Tasks

Instance Methods

cancelCurrentImageLoad

Cancel the current download

- (void)cancelCurrentImageLoad

Discussion

Cancel the current download

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

Set the imageView image with an url.

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

Set the imageView image with an url and a placeholder.

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

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

The downloand is asynchronous and cached.

Declared In

UIImageView+WebCache.h

setImageWithURL:placeholderImage:options:success:failure:

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

- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options success:(void ( ^ ) ( UIImage *image ))success failure:(void ( ^ ) ( NSError *error ))failure

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.

success

A block to be executed when the image request succeed This block has no return value and takes the retrieved image as argument.

failure

A block object to be executed when the image request failed. This block has no return value and takes the error object describing the network or parsing error that occurred (may be nil).

Discussion

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

The downloand is asynchronous and cached.

Declared In

UIImageView+WebCache.h

setImageWithURL:placeholderImage:success:failure:

Set the imageView image with an url, placeholder.

- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder success:(void ( ^ ) ( UIImage *image ))success failure:(void ( ^ ) ( NSError *error ))failure

Parameters

url

The url for the image.

placeholder

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

success

A block to be executed when the image request succeed This block has no return value and takes the retrieved image as argument.

failure

A block object to be executed when the image request failed. This block has no return value and takes the error object describing the network or parsing error that occurred (may be nil).

Discussion

Set the imageView image with an url, placeholder.

The downloand is asynchronous and cached.

Declared In

UIImageView+WebCache.h

setImageWithURL:success:failure:

Set the imageView image with an url.

- (void)setImageWithURL:(NSURL *)url success:(void ( ^ ) ( UIImage *image ))success failure:(void ( ^ ) ( NSError *error ))failure

Parameters

url

The url for the image.

success

A block to be executed when the image request succeed This block has no return value and takes the retrieved image as argument.

failure

A block object to be executed when the image request failed. This block has no return value and takes the error object describing the network or parsing error that occurred (may be nil).

Discussion

Set the imageView image with an url.

The downloand is asynchronous and cached.

Declared In

UIImageView+WebCache.h