UITableView Lazy Image Load, images appear after t

2020-05-28 11:07发布

I implemented lazy image load for my UITableView using NSUrlConnection. This is all working very nicely. When I open my table, I automatically get the images when I wait for a second (on 3G). However, when I scroll, the table loads the new cell's, starts the NSURLConnections, but when the image is finished loading (in code), they do not get put into the view until the table actually stops scrolling..

The Youtube application is able to load the images into the table WHILE scrolling, I'd like to do this as well, any hints / pointers?

2条回答
2楼-- · 2020-05-28 11:50

I just found my answer thanks to the 'Related' feature to the right.. Delayed UIImageView Rendering in UITableView

You have to start NSUrlConnection in a different run-loop, so that you receive data while the table is scrolling.

Thanks for the answers!

查看更多
三岁会撩人
3楼-- · 2020-05-28 11:57

Take a look at the Apple example LazyTableImages.

If you request all the images for your table asynchronously, they will load as they arrive.

You'll notice some applications wait for scrollViewDidEndDragging and loadImagesForOnscreenRows to be truly lazy and only request images for rows the user is currently examining.

查看更多
登录 后发表回答