我在UiTableViewController工作,我用XIB创建了Custom cell。我只是将黑色设置为一个标签。听到我附上三张图片以便更好地解释。
在didSelectRowAtIndexPath
方法中选择时,我将其更改为蓝色。
主要问题是当我只是滚动我的表格时,那个标签的背景颜色变得清晰。
在cellForRowAtIndexpath方法中,我只是添加了这个条件,
if (inboxSelcted == 1) {
cell.lblNoOfIndexItem.backgroundColor = [UIColor blueColor];
} else {
cell.lblNoOfIndexItem.backgroundColor = [UIColor blackColor];
}
答案 0 :(得分:3)
在 cellForRowAtIndexpath 方法中,根据您的屏幕截图收件箱索引是这样尝试2.所以,
if (indexPath.row == 2) {
cell.lblNoOfIndexItem.backgroundColor = [UIColor blueColor];
} else {
cell.lblNoOfIndexItem.backgroundColor = [UIColor blackColor];
}
在 didSelectRowAtIndexPath 方法中,
if (indexPath.row == 2) {
inboxSelcted = indexPath.row;
}
尝试这样,让我知道,它是否有效!