3

我有一个UITableViewCell基于 Storyboard Prototype 单元的自定义。在我的自定义单元格类中,我根据单元格状态“选定”或“突出显示”为单元格着色,代码如下所示:

- (void)updateCellDisplay {
    if (self.selected || self.highlighted) {
        self.label.textColor = [UIColor whiteColor];
        self.backgroundColor = [UIColor myLightBlueColor];
    } else {
        self.label.textColor = [UIColor blackColor];
        self.backgroundColor = [UIColor whiteColor];
    }
}

- (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated {
    [super setHighlighted:highlighted animated:animated];
    [self updateCellDisplay];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    [self updateCellDisplay];
}

现在我在 iOS7 中出现了这种奇怪的行为,即在选择结束后,单元格将自身重新绘制为完全蓝色。标签不再可见。看起来该单元格具有覆盖所有内容的前景色。这适用于 iOS7 之前的所有 iOS 版本。

在此处输入图像描述

在此处输入图像描述

在此处输入图像描述

那会是什么?

4

1 回答 1

0

似乎单元格的 contentView 在内容之上。我有一个类似的问题,并通过在 cellForRowAtIndexPath 的 contentView 中添加我的自定义项目来解决它。

就我而言,这些项目没有收到触摸,因为 contentView 已经结束。

[[cell contentView] addSubview:cell.itemTitleView]

我希望它有所帮助。

于 2013-09-29T20:03:16.283 回答