我正在使用自定义的UITableViewCell。它们装载得很好,但是当它们被重新使用而不是替换标签中的文本时,它们是如何写在其上面的。任何想法如何阻止这种行为?UITableViewCell - 重用时在数据顶部显示数据的视图
我假设在重用之前我没有正确重置视图。我目前是空的标签,所以他们只有一个空白的@“”字符串。但我仍然得到旧文本加上新的(非常混乱)。我确定有一个明显的解决方案(目前我只是不重用该单元格,但这不是最佳实践,并且在旧设备上很慢),所以如果有人可以帮助我会很感激。
感谢
ED
如这里要求是修改小区
static NSString *CellIdentifier = @"Cell";
TransactionCellView *cell = (TransactionCellView *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if(cell == nil) {
[[NSBundle mainBundle] loadNibNamed:@"TransactionCellView" owner:self options:nil];
cell = tblCell;
}
[cell resetCell]; // clears the labels
[cell setData:[dataArray objectAtIndex:[indexPath row]]; // replaces the data and updates the labels
return cell;
}
尝试在tableView上使用reload()... – 2011-06-06 15:57:20
您可以包含您的cellForRowAtIndexPath的代码 – Dancreek 2011-06-06 16:22:40
感谢您的答案,将在今天晚些时候尝试其中一些并相应地进行更新。再次感谢 – Harold 2011-06-08 10:13:37