我对 UITableViewCell 进行了子类化,这样我就可以提高滚动性能,这对我来说效果很好。
在我的子类中,我有一个名为 seSelected 的方法,看起来像这样
- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
[super setSelected:selected animated:animated];
// Configure the view for the selected state
if (selected) {
self.backgroundColor = [UIColor lightGrayColor];
}else{
self.backgroundColor = [UIColor whiteColor];
}
}
我想知道如何制作它,以便如果我触摸同一个单元格,它会取消选择该单元格并将颜色更改回白色?我在 setSelected 中尝试了一些不同的 if 语句,但没有任何效果。