美文网首页iOS第三方框架使用技巧
获取SDWebImage缓存在本地的图片

获取SDWebImage缓存在本地的图片

作者: iOS_Developer | 来源:发表于2016-07-11 11:26 被阅读3145次

    -(UIImage*)imageFromSdcache{

    NSData*imageData =nil;

    BOOLisExit = [[SDWebImageManagersharedManager]diskImageExistsForURL:[NSURLURLWithString:self.status.focus_pic]];

    if(isExit) {

    NSString*cacheImageKey = [[SDWebImageManagersharedManager]cacheKeyForURL:[NSURLURLWithString:self.status.focus_pic]];

    if(cacheImageKey.length) {

    NSString*cacheImagePath = [[SDImageCachesharedImageCache]defaultCachePathForKey:cacheImageKey];

    if(cacheImagePath.length) {

    imageData = [NSDatadataWithContentsOfFile:cacheImagePath];

    }

    }

    }

    if(!imageData) {

    imageData = [NSDatadataWithContentsOfURL:[NSURLURLWithString:self.status.focus_pic]];

    }

    UIImage*image = [UIImageimageWithData:imageData];

    returnimage;

    }

    相关文章

      网友评论

      本文标题:获取SDWebImage缓存在本地的图片

      本文链接:https://www.haomeiwen.com/subject/eyfjjttx.html