SDWebImage是否支持“非快速滚动"? (略读)是否需要延迟加载? [英] Does SDWebImage support "not-when-fast-scrolling" (skimming) for lazy loading?

查看:126
本文介绍了SDWebImage是否支持“非快速滚动"? (略读)是否需要延迟加载?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

进行延迟加载时(UICollectionView的表),

When doing lazy loading (table of UICollectionView),

为获得正确的结果,当用户在集合上快速滚动时,您不应开始下载.

for a correct result, you should NOT begin downloads, when the user is scrolling very quickly over the collection.

因此,想象一下一个垂直滚动,其中有200个面板,每个面板上都有一个图像;一次可以看到四个或五个.

So, imagine a vertical scroll with 200 panels each with an image; four or five are seen onscreen at a time.

首次加载时,应该开始加载前4个可见图像.如果向下滚动一点,新的可见图像应开始加载.

When it first loads, the first 4 visible images should begin loading. If you scroll down a little, the newly visible images should begin to load.

但是如果用户:非常迅速地向下滚动到(例如)位置100,然后将显示项目100-104的视图定位... ...理想情况下,您不应该开始快速加载用户略过"的图像(例如(从4到99),只有当用户停止非常快速地滚动并且显然在某些图像上停止或减速时,您才应开始下载.

BUT if the user: very quickly scrolls down to (say) position 100 and then positions the view showing items 100-104 ... you ideally SHOULD NOT starting loading the images which the user "skimmed" over very quickly (say, 4 through 99), you should only kick in the downloads when the user stops scrolling very quickly, and apparently is stopping or slowing on some images.

因此,这是任何高质量的延迟加载滚动中都必须执行的标准操作.用户浏览时不会开始加载.

So, this is a standard thing you have to do in any high-quality lazy-loading scroll. You don't start loading when the user is skimming.

我的问题很简单:SDWebImage是否支持此概念?如果没有,还有另一种流行的现成方法吗?干杯

My question is simply: does SDWebImage support this concept? If not is there another popular ready-made approach? Cheers

推荐答案

它不支持它,因为它通常是图像视图上的一个类别,但是您自己添加此功能将非常简单.

It doesn't support it, because it's usually a category on an image view, but it would be pretty straightforward to add the ability yourself.

假设您正在启动cellForItem...中的图像加载,则将在代码块后添加一个分派,如果只有相同的单元格在0.2秒后仍具有相同的索引路径,该分派将仅启动该加载.

Assuming you were kicking off the image load in cellForItem..., you'd add a dispatch after block which would only kick off the load if the same cell still had the same index path after, say, 0.2 seconds.

在执行任何操作之前,我会先检查您是否有可衡量的问题,但是-AFAIK SDWebImage(当然还有AFNetworking图像视图类别)将在收到新的URL请求时取消所有未完成的URL请求,因此您可能不必要了优化.

I'd check if you had a measurable problem before doing anything, though - AFAIK SDWebImage (and definitely the AFNetworking image view category) will cancel any outstanding URL requests when a new one is received, so you might be making an unnecessary optimisation.

这篇关于SDWebImage是否支持“非快速滚动"? (略读)是否需要延迟加载?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆