我试图点击时更改自定义单元格的背景颜色。这里是我的代码:自定义更改的backgroundColor的UITableViewCell不会显示
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView cellForRowAtIndexPath: indexPath];
if (...condition...) {
cell.backgroundColor = [UIColor clearColor];
} else {
cell.backgroundColor = [UIColor yellowColor];
}
}
现在,我做了调试和细胞.backgroundColor = [UIColor clearColor];被执行,但细胞保持黄色!这只发生在一些细胞(那些是黄色的,重复使用)。
有什么建议吗?