具有标识符的多个自定义单元格 - 重新加载表 - 低内存

时间:2014-06-19 16:14:44

标签: ios uitableview memory-management

我有UITableView使用自定义单元格。共有5种不同类型的小区标识符。

我nib文件相关 - CustomCell .h.m文件。它提供了几个标签和图像。

在storyborad中,我创建了5 UITableViewCell和子类CustomCell.h,但标识符不同。每个单元格都可以使用CustomCell.h

中的某些标签或图片

每次我使用[self.tableview reloadData];它会在记忆中创建新单元格。

CustomeCell无法出列,导致内存不足和最终应用程序崩溃。这是对的吗?

每次[self.tableview reloadData];调用时,新单元格都会添加到内存中而不是重用它们。如何发布较旧的细胞?

[图片更新]


在View控制器表视图中,客户单元格具有不同的标识符

enter image description here

其中一个如下。 enter image description here

TableView行

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSString *identifier = [self calculateIdentifier:indexPath.row];// This will retrun Identifier @"LabelCell" etc.

    ControlCell *cell = (ControlCell *)[tableView dequeueReusableCellWithIdentifier:identifier];

    cell.questionLabel.text = [self calculateQue:indexPath.row];
    cell.answerLabel.text = [self calculateAns:indexPath.row];

    return cell;
}

0 个答案:

没有答案