异步图像下载到表中
我有一个表视图,我想异步下载图标图像(100x75)到每一行。到目前为止,我已经遵循了很多教程,但我似乎无法弄清楚。我该怎么做呢?
是否有人建议使用标准 NSURLConnection API 来执行此操作,或者我应该使用在线可用的类/库之一来执行此操作?如果是这样,您有什么建议?
当然,我需要它快速、高效、不泄漏。我也不希望下载影响滚动。
谢谢你!
I have a table view and I'd like to download an icon image (100x75) to each row asynchronously. I've followed many tutorials so far but I can't seem to figure it out. How should I do it?
Does anyone recommend just doing it using the standard NSURLConnection API or should I use one of those classes/libraries that are available online to do so? If so, what do you recommend?
Of course, I need it to be fast, efficient and does not leak. I also don't want the downloading to affect the scrolling.
Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我能想到的两个选项:
(1)使用ASIHTTPRequest。
(2) 一个自定义实现,它生成一个线程,您可以在其中使用
NSURL
/NSData
的组合加载图像。加载图像后,使用performSelectorOnMainThread:withObject:
将其发送到主 UI 线程上的方法。Two options I can think of:
(1) Use ASIHTTPRequest.
(2) A custom implementation that spawns a thread in which you load the image using a combination of
NSURL
/NSData
. Once the image is loaded, send it to a method on the main UI thread usingperformSelectorOnMainThread:withObject:
.我建议您使用 ASIHTTPRequest。它简单而且相当快。
这是文档的链接 - ASIHTTPRequest
编辑
您只需下载可见单元格的图像。
这是一个示例:
无论如何,您需要编写大量代码才能使事情顺利快速地运行。
I'd recommend you using ASIHTTPRequest. Its simple and pretty fast.
Here is a link to the documentation - ASIHTTPRequest
EDIT
You need to download images for visible cells only.
Heres a sample:
Anyway u'll need to code a lot to make things work good and fast.