【发布时间】:2016-08-23 18:35:03
【问题描述】:
我想限制 SDImageCache 的内存缓存和磁盘缓存的大小。 以下是我用于下载图像的代码。默认情况下,它将图像保存在缓存中,并且存在于沙盒的库文件夹中。
我的申请 ID/Library/Caches/com.hackemist.SDWebImageCache.default/
#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;
}
【问题讨论】:
标签: ios caching sdwebimage