How to get filesystem path to image cached with SDWebImage (iOS)

好久不见. 提交于 2019-11-29 16:15:47
rufo

I had a similar problem, see: SDWebImage showing placeholder for images in cache

Basically I forked the project to resolve this.

Update:

You can just do this to avoid the flickering (this works with the master branch of the project):

[imageView setImageWithURL:url placeholderImage:imageView.image options:0 
 progress:^(NSUInteger receivedSize, long long expectedSize) {
        imageView.image = [UIImage imageNamed:@"QuestionMarkFace.png"];
 } completed:nil];

There are private SDImageCache methods to get filesystem path to cached image. We can make these methods public with a category. Just put the code below into the, say, SDImageCache+Private.h and add it to your project:

#import "SDImageCache.h"

@interface SDImageCache (PrivateMethods)

- (NSString *)defaultCachePathForKey:(NSString *)key;
- (NSString *)cachedFileNameForKey:(NSString *)key;

@end
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!