0

我有一个可下载项目的 UITableView,我使用另一个 UITableView 作为下载项目信息。如何重新加载所有 UITableViewCell 的 UiTableView?

我尝试使用[downloadList reloadData];,但它只会刷新大表。

编辑:我正在尝试做这样的事情:jsfiddle.net/WrNFU。我希望细节正确对齐,但问题是标题可能太长,我不确定标题将使用多少行。我使用了第二个表,因为 heightForRowAtIndexPath 函数使我能够调整标题行的高度。

回答:

使用我在这里找到的代码:iPad:遍历 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

1 回答 1

1

使用单个 UITableView(无需使用嵌套的 tableviews),您可以将每个项目(书?)视为单个 UITableViewCell 并处理不同大小的内容。

Yu需要计算UITableViewCell的高度并设置

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;

以便 tableview 知道内容的大小。当然,您还必须调整标签的大小以适合文本。

还有

- (void)reloadRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation NS_AVAILABLE_IOS(3_0);

下载完成后可用于重新加载单个单元格。

仍然不清楚为什么要重新加载单个单元格,是否在显示视图时开始下载每个项目?您是只下载显示的文本还是完整的文件?我觉得它可以以更简单的方式处理。

于 2013-11-12T11:11:52.257 回答