简体   繁体   English

在UITableViewCell中异步但按顺序加载图像URL

[英]Image url loading in UITableViewCell Asynchronously But in a order

I am using SDWebImage for loading image in a asynchronously to avoid blocking of UI. 我正在使用SDWebImage异步加载图像以避免阻塞UI。 But Image are not loading in a order way. 但是图像不是按顺序加载的。

这是我的问题

I want to load image in a ordered way but asynchronously. 我想以有序方式但异步加载图像。 I don't have exact word to define my problem. 我没有确切的词来定义我的问题。 If you find any suitable words please edit my question. 如果您找到任何合适的词,请编辑我的问题。

Please provide me appropriate solution for it. 请为我提供适当的解决方案。 It would be great if there is any third party library like SDWebImage to catch my requirement. 如果有像SDWebImage这样的第三方库来满足我的要求,那就太好了。 Or it can be done with SDWebImage. 或者可以使用SDWebImage完成。

If you want to load your images in order, that is not what asynchronous is about... Asynchronous means, that all images currently visible are loading at the same time. 如果要按顺序加载图像,则这与异步无关。...异步意味着,当前可见的所有图像将同时加载。 But you don't know which image will be loaded the first, so that's why this happens. 但是您不知道将首先加载哪个图像,所以这就是为什么会发生这种情况。

If you would send a request for every image, and then wait for the response before you send a new request, this would take way to much time. 如果您要发送每个图像的请求,然后在发送新请求之前等待响应,这将花费很多时间。

What you can do is, still load them asynchronously, but show them in an ordered way. 您可以做的是,仍然异步加载它们,但以有序方式显示它们。

I see that you can load images independently too, so one option is to load the images that currently visible, and then show them in an order with the help of a counter. 我看到您也可以独立加载图像,因此一种选择是加载当前可见的图像,然后在计数器的帮助下按顺序显示它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM