刷新UITableView [英] Refreshing a UITableView

查看:70
本文介绍了刷新UITableView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用于单元格的UITableView子类和UITableViewCell子类。我预先建立了所有单元格并将它们存储在cellForRowAtIndexPath中使用的数组中。除此之外,我还有一个线程在后台在每个单元格中加载一些图像。问题在于,单元格的刷新速度不如加载图像时快。例如,如果我不滚动表格视图,则只有在修改了所有单元格并且退出线程后,才会刷新第一个单元格。

I have a UITableView subclass and a UITableViewCell subclass that I'm using for cells. I'm bulding all my cells in advance and store them in an array from where I use them in cellForRowAtIndexPath. Aside from this I have a thread that loads some images in each cell, in the background. The problem is that the cells don't get refreshed as fast as the images are loaded. For example, if I don't scroll my table view, the first cells only get refreshed when all cells have been modified and the thread has exited.

关于如何操作的任何想法我可以有效地刷新表格视图/单元格吗?

Any ideas on how I can effectively refresh my tableview/cell?

推荐答案

您是否尝试过调用 [cell setNeedsDisplay] ,但是

Have you tried calling [cell setNeedsDisplay] but on the main thread?

setNeedsDisplay在后台线程上调用时几乎没有任何作用,

setNeedsDisplay when called on a background thread does pretty much nothing,

尝试一下:

[cell performSelectorOnMainThread:@selector(setNeedsDisplay) withObject:nil waitUntilDone:NO];

这篇关于刷新UITableView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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