我有UITableView
使用自定义单元格。共有5种不同类型的小区标识符。
我nib文件相关 - CustomCell .h
和.m
文件。它提供了几个标签和图像。
在storyborad中,我创建了5 UITableViewCell
和子类CustomCell.h
,但标识符不同。每个单元格都可以使用CustomCell.h
每次我使用[self.tableview reloadData];
它会在记忆中创建新单元格。
CustomeCell无法出列,导致内存不足和最终应用程序崩溃。这是对的吗?
每次[self.tableview reloadData];
调用时,新单元格都会添加到内存中而不是重用它们。如何发布较旧的细胞?
[图片更新]
在View控制器表视图中,客户单元格具有不同的标识符
其中一个如下。
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;
}