异步下载图像在表 [英] Async Images Download in a Table
问题描述
我有一个表视图和我想的图标图像(100x75)下载到每一行异步。到目前为止,我已经跟着很多教程,但我似乎无法弄清楚。我应该怎么办呢?
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?
有谁建议只是在做它使用标准的API NSURLConnection的,或者我应该使用这些类/库,可在网上这样做的吗?如果是这样,你有什么建议?
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.
感谢您!
推荐答案
我建议你使用ASIHTT prequest。其简单和pretty快。结果
下面是该文档的链接 - ASIHTT prequest
I'd recommend you using ASIHTTPRequest. Its simple and pretty fast.
Here is a link to the documentation - ASIHTTPRequest
修改
您需要下载图片,只可见单元格。
下面有一个例子:
You need to download images for visible cells only. Heres a sample:
- (void)loadContentForVisibleCells
{
NSArray *cells = [self.tableView visibleCells];
[cells retain];
for (int i = 0; i < [cells count]; i++)
{
...
// Request should be here
...
}
[cells release];
}
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate;
{
if (!decelerate)
{
[self loadContentForVisibleCells];
}
}
反正日子会把你需要code很多,使事情的工作又好又快。
Anyway u'll need to code a lot to make things work good and fast.
这篇关于异步下载图像在表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!