Update README.md.
Signed-off-by: 庞博 <bopang@sohu-inc.com>
Showing
1 changed file
with
23 additions
and
24 deletions
@@ -41,7 +41,7 @@ API documentation is available at [CocoaDocs - SDWebImage](http://cocoadocs.org/ | @@ -41,7 +41,7 @@ API documentation is available at [CocoaDocs - SDWebImage](http://cocoadocs.org/ | ||
41 | 41 | ||
42 | ### Using UIImageView+WebCache category with UITableView | 42 | ### Using UIImageView+WebCache category with UITableView |
43 | 43 | ||
44 | -Just #import the UIImageView+WebCache.h header, and call the setImageWithURL:placeholderImage: | 44 | +Just #import the UIImageView+WebCache.h header, and call the sd_setImageWithURL:placeholderImage: |
45 | method from the tableView:cellForRowAtIndexPath: UITableViewDataSource method. Everything will be | 45 | method from the tableView:cellForRowAtIndexPath: UITableViewDataSource method. Everything will be |
46 | handled for you, from async downloads to caching management. | 46 | handled for you, from async downloads to caching management. |
47 | 47 | ||
@@ -62,9 +62,9 @@ handled for you, from async downloads to caching management. | @@ -62,9 +62,9 @@ handled for you, from async downloads to caching management. | ||
62 | reuseIdentifier:MyIdentifier] autorelease]; | 62 | reuseIdentifier:MyIdentifier] autorelease]; |
63 | } | 63 | } |
64 | 64 | ||
65 | - // Here we use the new provided setImageWithURL: method to load the web image | ||
66 | - [cell.imageView setImageWithURL:[NSURL URLWithString:@"http://www.domain.com/path/to/image.jpg"] | ||
67 | - placeholderImage:[UIImage imageNamed:@"placeholder.png"]]; | 65 | + // Here we use the new provided sd_setImageWithURL: method to load the web image |
66 | + [cell.imageView sd_setImageWithURL:[NSURL URLWithString:@"http://www.domain.com/path/to/image.jpg"] | ||
67 | + placeholderImage:[UIImage imageNamed:@"placeholder.png"]]; | ||
68 | 68 | ||
69 | cell.textLabel.text = @"My Text"; | 69 | cell.textLabel.text = @"My Text"; |
70 | return cell; | 70 | return cell; |
@@ -77,10 +77,10 @@ With blocks, you can be notified about the image download progress and whenever | @@ -77,10 +77,10 @@ With blocks, you can be notified about the image download progress and whenever | ||
77 | has completed with success or not: | 77 | has completed with success or not: |
78 | 78 | ||
79 | ```objective-c | 79 | ```objective-c |
80 | -// Here we use the new provided setImageWithURL: method to load the web image | ||
81 | -[cell.imageView setImageWithURL:[NSURL URLWithString:@"http://www.domain.com/path/to/image.jpg"] | ||
82 | - placeholderImage:[UIImage imageNamed:@"placeholder.png"] | ||
83 | - completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType) {... completion code here ...}]; | 80 | +// Here we use the new provided sd_setImageWithURL: method to load the web image |
81 | +[cell.imageView sd_setImageWithURL:[NSURL URLWithString:@"http://www.domain.com/path/to/image.jpg"] | ||
82 | + placeholderImage:[UIImage imageNamed:@"placeholder.png"] | ||
83 | + completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {... completion code here ...}]; | ||
84 | ``` | 84 | ``` |
85 | 85 | ||
86 | Note: neither your success nor failure block will be call if your image request is canceled before completion. | 86 | Note: neither your success nor failure block will be call if your image request is canceled before completion. |
@@ -95,19 +95,18 @@ Here is a simple example of how to use SDWebImageManager: | @@ -95,19 +95,18 @@ Here is a simple example of how to use SDWebImageManager: | ||
95 | 95 | ||
96 | ```objective-c | 96 | ```objective-c |
97 | SDWebImageManager *manager = [SDWebImageManager sharedManager]; | 97 | SDWebImageManager *manager = [SDWebImageManager sharedManager]; |
98 | -[manager downloadWithURL:imageURL | ||
99 | - options:0 | ||
100 | - progress:^(NSInteger receivedSize, NSInteger expectedSize) | ||
101 | - { | ||
102 | - // progression tracking code | ||
103 | - } | ||
104 | - completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished) | ||
105 | - { | ||
106 | - if (image) | ||
107 | - { | ||
108 | - // do something with image | ||
109 | - } | ||
110 | - }]; | 98 | +[manager downloadImageWithURL:imageURL |
99 | + options:0 | ||
100 | + progress:^(NSInteger receivedSize, NSInteger expectedSize) | ||
101 | + { | ||
102 | + // progression tracking code | ||
103 | + } | ||
104 | + completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) | ||
105 | + { | ||
106 | + if (image) { | ||
107 | + // do something with image | ||
108 | + } | ||
109 | + }]; | ||
111 | ``` | 110 | ``` |
112 | 111 | ||
113 | ### Using Asynchronous Image Downloader Independently | 112 | ### Using Asynchronous Image Downloader Independently |
@@ -207,9 +206,9 @@ SDWebImage does very aggressive caching by default. It ignores all kind of cachi | @@ -207,9 +206,9 @@ SDWebImage does very aggressive caching by default. It ignores all kind of cachi | ||
207 | 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: | 206 | 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: |
208 | 207 | ||
209 | ``` objective-c | 208 | ``` objective-c |
210 | -[imageView setImageWithURL:[NSURL URLWithString:@"https://graph.facebook.com/olivier.poitrey/picture"] | ||
211 | - placeholderImage:[UIImage imageNamed:@"avatar-placeholder.png"] | ||
212 | - options:SDWebImageRefreshCached]; | 209 | +[imageView sd_setImageWithURL:[NSURL URLWithString:@"https://graph.facebook.com/olivier.poitrey/picture"] |
210 | + placeholderImage:[UIImage imageNamed:@"avatar-placeholder.png"] | ||
211 | + options:SDWebImageRefreshCached]; | ||
213 | ``` | 212 | ``` |
214 | 213 | ||
215 | ### Add a progress indicator | 214 | ### Add a progress indicator |
-
Please register or login to post a comment