SDWebImage 下载图片

//下载图片获取下载进度  

//头文件导入

[self.myimage sd_setImageWithURL:[NSURL URLWithString:@""] placeholderImage:[UIImage imageNamed:@""] options:0 progress:^(NSInteger receivedSize, NSInteger expectedSize) {            } completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {            }];   

//只需要简单获取图片

//内存缓存&磁盘缓存    头文件导入

[[SDWebImageManager sharedManager]downloadImageWithURL:[NSURL URLWithString:@""] options:0 progress:^(NSInteger receivedSize, NSInteger expectedSize) {            } completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {        self.myimage.image = image;

  }];   

//不需要任务的缓存处理  头文件导入

[[SDWebImageDownloader sharedDownloader]downloadImageWithURL:[NSURL URLWithString:@""] options:0 progress:^(NSInteger receivedSize, NSInteger expectedSize) {

} completed:^(UIImage *image, NSData *data, NSError *error, BOOL finished) {

[[NSOperationQueue mainQueue]addOperationWithBlock:^{

self.myimage.image = image;

}];

}];

你可能感兴趣的:(SDWebImage 下载图片)