iOS第三方框架使用技巧

获取SDWebImage缓存在本地的图片

2016-07-11  本文已影响3145人  iOS_Developer

-(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;

}

上一篇下一篇

猜你喜欢

热点阅读