0
我是初学者。我想通过对TableView中的URL来显示图像,所以我用AFNetworking + SDURLCache,就像下面“缓存图片”和“本地图片”有什么不同?
// init URLCache
SDURLCache *URLCache = [[SDURLCache alloc] initWithMemoryCapacity:1024*1024*2 diskCapacity:1024*1024*20 diskPath:[SDURLCache defaultCachePath]];
[URLCache setIgnoreMemoryOnlyStoragePolicy:YES];
[SDURLCache setSharedURLCache:URLCache];
======================= =================================
// set cell
[cell.imageView setImageWithURL:[NSURL URLWithString:IMAGE_URL] placeholderImage:[UIImage imageNamed:@"placeholder.png"]];
[[SDURLCache sharedURLCache] cachedResponseForRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:IMAGE_URL]]];
在这里,我使用了一个图像上的所有不同的细胞。一切正常!当我第一次运行我的项目时,在单元上显示图像需要很长时间,因为我的网页图像非常大。当我第二次运行我的项目时,我发现TableView立即加载图像 ?为什么?为什么不立即加载所有图像。我将缓存的图像替换为本地图像,TableView一次加载图像。 “缓存图像”和“本地”图像有什么不同? SDURLCache没有工作?
你的图像有多大? 50KB? 1MB? –
我的图像是185KB – expl