0
我正在制作一个应用程序,其中有来自名为openears
和tableView
的数组中的名人引用,其中显示了所有引号。当前阅读的报价将以不同于其他报价的颜色显示在tableview中。我尝试了cellForRowAtIndexPath
中的以下功能,但单元格的颜色保持不变,除非用户将其滚动出来然后返回到视图。但我需要自动设置颜色,同时所有其他单元应恢复为初始(白色)颜色。有什么方法可以做到这一点?我不想每次重新加载表来实现这一点。在滚动上编辑UITableViewCell属性
if ([[arrayOfQuoteIds objectAtIndex:indexPath.row]intValue] == currentQuoteId) {
cell.backgroundColor = [self colorWithHexString:@"D3FFFF"];
cell.contentView.backgroundColor = [self colorWithHexString:@"D3FFFF"];
cell.textLabel.backgroundColor = [self colorWithHexString:@"D3FFFF"];
cell.detailTextLabel.backgroundColor = [self colorWithHexString:@"D3FFFF"];
cell.accessoryView.backgroundColor = [self colorWithHexString:@"D3FFFF"];
}
else {
cell.backgroundColor = [UIColor whiteColor];
cell.contentView.backgroundColor = [UIColor whiteColor];
cell.textLabel.backgroundColor = [UIColor whiteColor];
cell.detailTextLabel.backgroundColor = [UIColor whiteColor];
cell.accessoryView.backgroundColor = [UIColor whiteColor];
}