Web Image
=========
[![Build Status](http://img.shields.io/travis/rs/SDWebImage/master.svg?style=flat)](https://travis-ci.org/rs/SDWebImage)
[![Pod Version](http://img.shields.io/cocoapods/v/SDWebImage.svg?style=flat)](http://cocoadocs.org/docsets/SDWebImage/)
[![Pod Platform](http://img.shields.io/cocoapods/p/SDWebImage.svg?style=flat)](http://cocoadocs.org/docsets/SDWebImage/)
[![Pod License](http://img.shields.io/cocoapods/l/SDWebImage.svg?style=flat)](https://www.apache.org/licenses/LICENSE-2.0.html)
[![Dependency Status](https://www.versioneye.com/objective-c/sdwebimage/3.3/badge.svg?style=flat)](https://www.versioneye.com/objective-c/sdwebimage/3.3)
[![Reference Status](https://www.versioneye.com/objective-c/sdwebimage/reference_badge.svg?style=flat)](https://www.versioneye.com/objective-c/sdwebimage/references)
[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/rs/SDWebImage)
This library provides a category for UIImageView with support for remote images coming from the web.
It provides:
- An UIImageView category adding web image and cache management to the Cocoa Touch framework
- An asynchronous image downloader
- An asynchronous memory + disk image caching with automatic cache expiration handling
- Animated GIF support
- WebP format support
- A background image decompression
- A guarantee that the same URL won't be downloaded several times
- A guarantee that bogus URLs won't be retried again and again
- A guarantee that main thread will never be blocked
- Performances!
- Use GCD and ARC
- Arm64 support
NOTE: The version 3.0 of SDWebImage isn't fully backward compatible with 2.0 and requires iOS 5.1.1
minimum deployement version. If you need iOS < 5.0 support, please use the last [2.0 version](https://github.com/rs/SDWebImage/tree/2.0-compat).
[How is SDWebImage better than X?](https://github.com/rs/SDWebImage/wiki/How-is-SDWebImage-better-than-X%3F)
Who Use It
----------
Find out [who uses SDWebImage](https://github.com/rs/SDWebImage/wiki/Who-Uses-SDWebImage) and add your app to the list.
How To Use
----------
API documentation is available at [CocoaDocs - SDWebImage](http://cocoadocs.org/docsets/SDWebImage/)
### Using UIImageView+WebCache category with UITableView
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.
```objective-c
#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 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";
return cell;
}
```
### Using blocks
With blocks, you can be notified about the image download progress and whenever the image retrival
has completed with success or not:
```objective-c
// 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, NSURL *imageURL) {... completion code here ...}];
```
Note: neither your success nor failure block will be call if your image request is canceled before completion.
### Using SDWebImageManager
The SDWebImageManager is the class behind the UIImageView+WebCache category. It ties the
asynchronous downloader with the image cache store. You can use this class directly to benefit
from web image downloading with caching in another context than a UIView (ie: with Cocoa).
Here is a simple example of how to use SDWebImageManager:
```objective-c
SDWebImageManager *manager = [SDWebImageManager sharedManager];
[manager downloadImageWithURL:imageURL
options:0
progress:^(NSInteger receivedSize, NSInteger expectedSize) {
// progression tracking code
}
completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
if (image) {
// do something with image
}
}];
```
### Using Asynchronous Image Downloader Independently
It's also possible to use the async image downloader independently:
```objective-c
[SDWebImageDownloader.sharedDownloader downloadImageWithURL:imageURL
options:0
progress:^(NSInteger receivedSize, NSInteger expectedSize)
{
// progression tracking code
}
completed:^(UIImage *image, NSData *data, NSError *error, BOOL finished)
{
if (image && finished)
{
// do something with image
}
}];
```
### Using Asynchronous Image Caching Independently
It is also possible to use the async based image cache store independently. SDImageCache
maintains a memory cache and an optional disk cache. Disk cache write operations are performed
asynchronous so it doesn't add unnecessary latency to the UI.
The SDImageCache class provides a singleton instance for convenience but you can create your own
instance if you want to create separated cache namespace.
To lookup the cache, you use the `queryDiskCacheForKey:done:` method. If the method returns nil, it means the cache
doesn't currently own the image. You are thus responsible for generating and caching it. The cache
key is an application unique identifier for the image to cache. It is generally the absolute URL of
the image.
```objective-c
SDImageCache *imageCache = [[SDImageCache alloc] initWithNamespace:@"myNamespace"];
[imageCache queryDiskCacheForKey:myCacheKey done:^(UIImage *image)
{
// image is not nil if image was found
}];
```
By default SDImageCache will lookup the disk cache if an image can't be found in the memory cache.
You can prevent this from happening by calling the alternative method `imageFromMemoryCacheForKey:`.
To store an image into the cache, you use the storeImage:forKey: method:
```objective-c
[[SDImageCache sharedImageCache] storeImage:myImage forKey:myCacheKey];
```
By default, the image will be stored in memory cache as well as on disk cache (asynchronously). If
you want only the memory cache, use the alternative method storeImage:forKey:toDisk: with a negative
third argument.
### Using cache key filter
Sometime, you may not want to use the image URL as cache key because part of the URL is dynamic
(i.e.: for access control purpose). SDWebImageManager provides a way to set a cache key filter that
takes the NSURL as input, and output a cache key NSString.
The fo
没有合适的资源?快使用搜索试试~ 我知道了~
XNChoosePictureView(图片选择器)
共369个文件
h:175个
m:109个
png:32个
需积分: 9 64 下载量 11 浏览量
2015-12-16
13:06:20
上传
评论
收藏 589KB ZIP 举报
温馨提示
详细介绍:http://blog.csdn.net/luohancc/article/details/50325853
资源推荐
资源详情
资源评论
收起资源包目录
XNChoosePictureView(图片选择器) (369个子文件)
.DS_Store 10KB
.DS_Store 8KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
UIButton+WebCache.h 13KB
UIFont+BFKit.h 12KB
SDWebImageManager.h 11KB
UIImageView+WebCache.h 10KB
SDImageCache.h 8KB
UIImage+BFKit.h 8KB
NSFileManager+BFKit.h 7KB
SDWebImageDownloader.h 7KB
NSDate+BFKit.h 6KB
BFSystemSound.h 6KB
MKAnnotationView+WebCache.h 6KB
UIDevice+BFKit.h 6KB
UIButton+BFKit.h 5KB
PhotoBroswerVC.h 5KB
UIImageView+HighlightedWebCache.h 5KB
UIView+BFKit.h 4KB
NSString+BFKit.h 4KB
SVProgressHUD.h 4KB
SDWebImagePrefetcher.h 4KB
UITextView+BFKit.h 4KB
UIColor+BFKit.h 4KB
UITextField+BFKit.h 3KB
UILabel+BFKit.h 3KB
SDWebImageDownloaderOperation.h 3KB
UITableView+BFKit.h 3KB
NSArray+BFKit.h 2KB
NSNumber+BFKit.h 2KB
NSMutableArray+BFKit.h 2KB
BFKit.h 2KB
UIScrollView+BFKit.h 2KB
BFLog.h 2KB
BFApp.h 2KB
LFRoundProgressView.h 2KB
BFTouchID.h 2KB
BFPassword.h 2KB
UIImageView+BFKit.h 2KB
SDWebImageCompat.h 2KB
CALayer+Transition.h 2KB
NSDictionary+BFKit.h 2KB
CoreSVP.h 2KB
UIWebView+BFKit.h 2KB
NSMutableDictionary+BFKit.h 2KB
CoreConst.h 2KB
MLSelectPhotoPickerCollectionView.h 2KB
MLSelectPhotoPickerViewController.h 2KB
UIWindow+BFKit.h 1KB
NSThread+BFKit.h 1KB
NSProcessInfo+BFKit.h 1KB
UIView+Extend.h 1KB
MLSelectPhotoPickerBrowserPhotoScrollView.h 1KB
PhotoItemView.h 1KB
CoreArchive.h 1KB
PhotoModel.h 1KB
MLSelectPhotoCommon.h 1KB
UIView+WebCacheOperation.h 970B
MLSelectPhoto.h 970B
MLSelectPhotoPickerDatas.h 960B
MLSelectPhotoPickerBrowserPhoto.h 941B
UIDevice+Extend.h 937B
NSDate+Extend.h 918B
UIImage+Color.h 868B
UIImage+Water.h 853B
UIImageView+SD.h 847B
MLSelectPhotoPickerAssetsViewController.h 836B
MLSelectPhotoPickerBrowserPhotoImageView.h 830B
MLSelectPhotoPickerGroup.h 824B
UIButton+SD.h 777B
XNChooesPictureView.h 758B
UIColor+Extend.h 754B
UIFont+Extend.h 730B
MLSelectPhotoPickerBrowserPhotoView.h 723B
CALayer+Anim.h 714B
MLSelectPhotoPickerGroupViewController.h 673B
UIImage+Extend.h 658B
UIView+MLExtension.h 610B
MLSelectPhotoBrowserViewController.h 604B
NSObject+BFKit.h 598B
MLSelectPhotoAssets.h 592B
Pods-environment.h 588B
MLPhotoPickerImageView.h 587B
UIImage+Cut.h 581B
NSString+File.h 578B
NSData+ImageContentType.h 565B
MLSelectPhotoPickerCollectionViewCell.h 540B
NSArray+Extend.h 533B
UIImage+WebP.h 490B
PhotoBroswerType.h 485B
MLSelectPhotoPickerGroupTableViewCell.h 473B
SDWebImageDecoder.h 453B
共 369 条
- 1
- 2
- 3
- 4
资源评论
LuohanCC
- 粉丝: 15
- 资源: 11
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功