【问题标题】:Where is the cache for SDWebImage?SDWebImage 的缓存在哪里?
【发布时间】:2016-08-23 01:26:07
【问题描述】:

我检查了 NSBundle,但找不到 SDWebImage 保存图像的缓存。是否启用了缓存(请参见下面的代码)?根据Docs,它负责缓存管理。

如文档中所述:

只需#import UIImageView+WebCache.h 头文件,然后调用 sd_setImageWithURL:placeholderImage: 方法来自 tableView:cellForRowAtIndexPath: UITableViewDataSource 方法。 一切都会为您处理,从异步下载到缓存 管理

#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


    【解决方案1】:

    在您沙盒的库文件夹中

    您的应用程序 ID/Library/Caches/com.hackemist.SDWebImageCache.default/

    【讨论】:

      【解决方案2】:

      在您的项目中搜索以下代码行。 _diskCachePathcachecache

      if (![_fileManager fileExistsAtPath:_diskCachePath]) {
                      [_fileManager createDirectoryAtPath:_diskCachePath withIntermediateDirectories:YES attributes:nil error:NULL];
                  }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2022-08-18
        • 2011-12-15
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多