2009-09-23 09:05:40 +08:00
|
|
|
/*
|
|
|
|
* This file is part of the SDWebImage package.
|
|
|
|
* (c) Olivier Poitrey <rs@dailymotion.com>
|
|
|
|
*
|
|
|
|
* For the full copyright and license information, please view the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
2010-06-02 07:37:39 +08:00
|
|
|
*/
|
2009-09-23 09:05:40 +08:00
|
|
|
|
|
|
|
#import "UIImageView+WebCache.h"
|
|
|
|
|
|
|
|
@implementation UIImageView (WebCache)
|
|
|
|
|
|
|
|
- (void)setImageWithURL:(NSURL *)url
|
|
|
|
{
|
2009-09-24 05:22:48 +08:00
|
|
|
[self setImageWithURL:url placeholderImage:nil];
|
|
|
|
}
|
2009-09-23 09:05:40 +08:00
|
|
|
|
2009-09-24 05:22:48 +08:00
|
|
|
- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder
|
2011-10-03 21:52:56 +08:00
|
|
|
{
|
|
|
|
[self setImageWithURL:url placeholderImage:placeholder options:0];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options
|
2009-09-24 05:22:48 +08:00
|
|
|
{
|
|
|
|
SDWebImageManager *manager = [SDWebImageManager sharedManager];
|
2009-09-23 09:05:40 +08:00
|
|
|
|
|
|
|
// Remove in progress downloader from queue
|
2009-09-24 05:22:48 +08:00
|
|
|
[manager cancelForDelegate:self];
|
|
|
|
|
2010-09-17 04:56:11 +08:00
|
|
|
self.image = placeholder;
|
2010-06-11 12:17:54 +08:00
|
|
|
|
2010-09-17 04:56:11 +08:00
|
|
|
if (url)
|
2009-09-23 09:05:40 +08:00
|
|
|
{
|
2011-10-03 21:52:56 +08:00
|
|
|
[manager downloadWithURL:url delegate:self options:options];
|
2009-09-23 09:05:40 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-06-11 22:32:35 +08:00
|
|
|
- (void)cancelCurrentImageLoad
|
2010-06-11 21:06:04 +08:00
|
|
|
{
|
|
|
|
[[SDWebImageManager sharedManager] cancelForDelegate:self];
|
|
|
|
}
|
|
|
|
|
2009-09-29 05:56:24 +08:00
|
|
|
- (void)webImageManager:(SDWebImageManager *)imageManager didFinishWithImage:(UIImage *)image
|
2009-09-24 05:22:48 +08:00
|
|
|
{
|
|
|
|
self.image = image;
|
|
|
|
}
|
|
|
|
|
2010-06-02 07:37:39 +08:00
|
|
|
@end
|