1
我有一个填充UITableView
的完整列表。我想用不同的颜色来背景单元格之一,它最初起作用,但由于某种原因,当我开始向上和向下滚动表格时,它开始绘制更多具有绿色背景的单元格。滚动时在UITableViewCell中错误地重复单元格背景
请注意,总是一个detailCell.detailTimeLabel.text
这等于currentTime
。
我的代码是:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
... SOME MORE CODE HERE ...
if ([detailCell.detailTimeLabel.text isEqualToString:currentTime]) {
UIView* backgroundView = [[[UIView alloc] initWithFrame:CGRectZero] autorelease];
backgroundView.backgroundColor = [UIColor greenColor];
detailCell.backgroundView = backgroundView;
for (UIView* view in detailCell.contentView.subviews)
{
view.backgroundColor = [UIColor clearColor];
}
}
}
它可以是问题吗?