...
|
...
|
@@ -41,7 +41,7 @@ API documentation is available at [CocoaDocs - SDWebImage](http://cocoadocs.org/ |
|
|
|
|
|
### Using UIImageView+WebCache category with UITableView
|
|
|
|
|
|
Just #import the UIImageView+WebCache.h header, and call the setImageWithURL:placeholderImage:
|
|
|
Just #import the UIImageView+WebCache.h header, and call the sd_setImageWithURL:placeholderImage:
|
|
|
method from the tableView:cellForRowAtIndexPath: UITableViewDataSource method. Everything will be
|
|
|
handled for you, from async downloads to caching management.
|
|
|
|
...
|
...
|
@@ -62,8 +62,8 @@ handled for you, from async downloads to caching management. |
|
|
reuseIdentifier:MyIdentifier] autorelease];
|
|
|
}
|
|
|
|
|
|
// Here we use the new provided setImageWithURL: method to load the web image
|
|
|
[cell.imageView setImageWithURL:[NSURL URLWithString:@"http://www.domain.com/path/to/image.jpg"]
|
|
|
// Here we use the new provided sd_setImageWithURL: method to load the web image
|
|
|
[cell.imageView sd_setImageWithURL:[NSURL URLWithString:@"http://www.domain.com/path/to/image.jpg"]
|
|
|
placeholderImage:[UIImage imageNamed:@"placeholder.png"]];
|
|
|
|
|
|
cell.textLabel.text = @"My Text";
|
...
|
...
|
@@ -77,10 +77,10 @@ With blocks, you can be notified about the image download progress and whenever |
|
|
has completed with success or not:
|
|
|
|
|
|
```objective-c
|
|
|
// Here we use the new provided setImageWithURL: method to load the web image
|
|
|
[cell.imageView setImageWithURL:[NSURL URLWithString:@"http://www.domain.com/path/to/image.jpg"]
|
|
|
// Here we use the new provided sd_setImageWithURL: method to load the web image
|
|
|
[cell.imageView sd_setImageWithURL:[NSURL URLWithString:@"http://www.domain.com/path/to/image.jpg"]
|
|
|
placeholderImage:[UIImage imageNamed:@"placeholder.png"]
|
|
|
completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType) {... completion code here ...}];
|
|
|
completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {... completion code here ...}];
|
|
|
```
|
|
|
|
|
|
Note: neither your success nor failure block will be call if your image request is canceled before completion.
|
...
|
...
|
@@ -95,16 +95,15 @@ Here is a simple example of how to use SDWebImageManager: |
|
|
|
|
|
```objective-c
|
|
|
SDWebImageManager *manager = [SDWebImageManager sharedManager];
|
|
|
[manager downloadWithURL:imageURL
|
|
|
[manager downloadImageWithURL:imageURL
|
|
|
options:0
|
|
|
progress:^(NSInteger receivedSize, NSInteger expectedSize)
|
|
|
{
|
|
|
// progression tracking code
|
|
|
}
|
|
|
completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished)
|
|
|
{
|
|
|
if (image)
|
|
|
completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL)
|
|
|
{
|
|
|
if (image) {
|
|
|
// do something with image
|
|
|
}
|
|
|
}];
|
...
|
...
|
@@ -207,7 +206,7 @@ SDWebImage does very aggressive caching by default. It ignores all kind of cachi |
|
|
If you don't control the image server you're using, you may not be able to change the URL when its content is updated. This is the case for Facebook avatar URLs for instance. In such case, you may use the `SDWebImageRefreshCached` flag. This will slightly degrade the performance but will respect the HTTP caching control headers:
|
|
|
|
|
|
``` objective-c
|
|
|
[imageView setImageWithURL:[NSURL URLWithString:@"https://graph.facebook.com/olivier.poitrey/picture"]
|
|
|
[imageView sd_setImageWithURL:[NSURL URLWithString:@"https://graph.facebook.com/olivier.poitrey/picture"]
|
|
|
placeholderImage:[UIImage imageNamed:@"avatar-placeholder.png"]
|
|
|
options:SDWebImageRefreshCached];
|
|
|
```
|
...
|
...
|
|