【发布时间】:2017-03-30 06:45:48
【问题描述】:
我在 UiTableViewController 中工作,并使用 XIB 创建了自定义单元格。我只是将黑色设置为一个标签。听说我附上了三张图片以便更好地解释。
在didSelectRowAtIndexPath 方法中选择时,我将其从黑色更改为蓝色。
主要问题是当我滚动表格时,该标签的背景颜色变得清晰。
在 cellForRowAtIndexpath 方法中,我只是添加了这个条件,
if (inboxSelcted == 1) {
cell.lblNoOfIndexItem.backgroundColor = [UIColor blueColor];
} else {
cell.lblNoOfIndexItem.backgroundColor = [UIColor blackColor];
}
【问题讨论】:
-
能否为 cellForRowAtIndexpath 添加代码?
-
你能用
cellForRow atindexPath函数编辑吗? -
在 cellForRowAtIndexpath 方法中,我只是添加了这个条件, if (inboxSelcted == 1) { cell.lblNoOfIndexItem.backgroundColor = [UIColor blueColor]; } else { cell.lblNoOfIndexItem.backgroundColor = [UIColor blackColor]; }
-
@PALAKiOSDeveloper 更新您问题中的代码
-
你能检查一下这个条件检查的外部范围吗?您可能有一些来自出队单元的默认行为(基本上来自 IB-UI)。如果是这种情况,您可以在单元格初始行之后为标签设置任何一种颜色。
标签: ios css objective-c uitableview uilabel