AFNetworking预取其他图像 [英] AFNetworking prefetch other images
问题描述
我正在使用 UIImageView + AFNetworking
类别从URL数组下载和显示图像并填充表格视图。
I am using the UIImageView + AFNetworking
category to download and display images from an array of URLs and populate a table view.
现在,我发现其他图像被延迟了,因为将仅加载当前单元格的图像。我还需要通过获取其他图像来保持忙碌。
Now I find that the other images are delayed because only the current cell's image will be loaded. I need to keep busy by fetching other images as well.
我的想法是编写一个for循环,并开始使用AFNetworking下载和缓存,例如另外10个请求从当前indexPath开始。
My idea would be to write a for loop and start downloading and caching with AFNetworking, say, 10 other requests starting from current indexPath
.
还是我应该照常做 dispatch_async
在完成代码块中并开始获取提到的其他20张图像?
Or should I just do the usual dispatch_async
in the completion block and start fetching the mentioned 20 other images?
还有更好的主意吗?
推荐答案
在大多数情况下,预取不会像您预期的那样带来好处。在移动设备上,功率和带宽是有限的资源,这使加载用户可能实际上从未见过的东西的价值产生了疑问。您很可能会聪明一点,对自己造成伤害。
In most cases, pre-fetching won't be nearly as beneficial as you might expect. On a mobile device, power and bandwidth are limited resources, which calls into question the value of loading things that a user may not actually ever see. You're most likely doing a disservice by trying to be clever about this.
这篇关于AFNetworking预取其他图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!