我在用户登录时缓存图片:
这是Utility.m
UIImage *image = [UIImage imageWithData:newProfilePictureData];
UIImage *mediumImage = [image thumbnailImage:280 transparentBorder:0 cornerRadius:0 interpolationQuality:kCGInterpolationHigh];
UIImage *smallRoundedImage = [image thumbnailImage:64 transparentBorder:0 cornerRadius:9 interpolationQuality:kCGInterpolationLow];
NSData *mediumImageData = UIImageJPEGRepresentation(mediumImage, 0.5); // using JPEG for larger pictures
NSData *smallRoundedImageData = UIImagePNGRepresentation(smallRoundedImage);
稍后我想将小图片加载到UIImageView
:
这是UITableView
- cellForRowAtIndexPath
[cell.leftIcon setImage:
有谁知道我如何引用缓存的图像?
答案 0 :(得分:0)
在Utility.m中需要类似下面的方法,
+(NSString*)getImage {
return smallRoundedImage;
}
然后像下面一样使用它,
[cell.leftIcon setImage:[Utility getImage]];
PS:这只是一个例子,你可以根据你的要求做得更好!