【发布时间】:2013-11-12 11:04:37
【问题描述】:
我有一个可下载项目的 UITableView,我使用另一个 UITableView 来获取下载项目信息。如何重新加载所有 UITableViewCell 的 UiTableView?
我尝试使用[downloadList reloadData];,但它只会刷新大表。
编辑: 我正在尝试做这样的事情:jsfiddle.net/WrNFU。我希望细节正确对齐,但问题是标题可能太长,我不确定标题将使用多少行。我使用了第二个表格,因为 heightForRowAtIndexPath 函数可以让我调整标题行的高度。
答案:
使用我在这里找到的代码:iPad: Iterate over every cell in a UITableView?
for (int section = 0; section < [downloadList numberOfSections]; section++) {
for (int row = 0; row < [downloadList numberOfRowsInSection:section]; row++) {
NSIndexPath* cellPath = [NSIndexPath indexPathForRow:row inSection:section];
UITableViewCell* cell = [downloadList cellForRowAtIndexPath:cellPath];
UITableView *tempTableView = (UITableView *)[cell viewWithTag:110];
[tempTableView reloadData];
}
}
【问题讨论】:
-
为什么你不使用一个表格视图自定义单元格?包含 4 个标签、2 个静态文本和 2 个是动态的。其中将标题标签 no.of.lines 设为 3 并处理表格的高度。