我想改变我的单元格背景色更改自定义背景色tableViewCell
我看其他的问题,但他们不符合我的情况
我想做一个通知的tableView
例如,如果用户已经阅读细胞,细胞的背景颜色将变为白色
如果不是,颜色为黄色
在开始
我设置
-(void)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath{
if(read[[indexPath row]])
[cell.backView setBckgroundColor:[UIColor whiteColor];
else
[cell.backView setBckgroundColor:[UIColor redColor];
}
它的工作原理的颜色,然后我想改变颜色
tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath{
read[[indexPath row]] = yes;
[cell.backView setBckgroundColor:[UIColor whiteColor];
cell.name.text = @"test";
}
它也能工作
但如果我选择其他细胞,它改变为原始颜色
它似乎只能改变一个单元的颜色相同时间
不管我用
cell.backgroundColor
cell.contentView.backgroundColor
cell.backView
它得到相同的结果,谁能帮助我
编辑4/20 20:13
我设置
阅读tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath
对不起方向,我更新代码
,我选择其他细胞后,我不叫[重装的tableView]
,所以我不认为这是什么原因
顺便说一句,一切都(E 。克标签)可以改变,但背景颜色
,如果我选择小区时,它通过导航
答跳转到其他屏幕
结论第一
tableView: cellForRowAtIndexPath: is well
和
tableView: willDisplayCell: is well too
他们都可以改变背景颜色
但执行时需要制定新的细胞或重装的tableView
我还是搞不清为什么我可以在didselectionRowAtIndexPath 更改标签,但我不能改变颜色
我这样做,但它不起作用,我再次编辑代码感谢 – jim