选择UITableViewCell时出了什么问题?

时间:2022-09-20 18:40:32

When I select a UITableViewCell the background become gray, the the gray height is strange. Some of the cell is strange like it.I set seperator line style to none. And I add labels to the front and foot cell ,so there are lines between cell.As is show In the first picture. The other cells are normal as what I expect showed in the second picture.

当我选择UITableViewCell时,背景变为灰色,灰色高度很奇怪。有些单元格很奇怪。我将分隔线样式设置为无。并且我在前面和底部单元格中添加标签,因此单元格之间有线条。如第一张图所示。正如我预期的那样,其他细胞是正常的。

选择UITableViewCell时出了什么问题?

选择UITableViewCell时出了什么问题?

1 个解决方案

#1


It seems that I have solve the problem. First set the :

看来我已经解决了这个问题。首先设置:

cell.selectionStyle = UITableViewCellSelectionStyleNone;

and the overwrite the method:

并覆盖方法:

- (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated
{
    if (highlighted) {
        self.contentView.backgroudColor= [UIColor gray];
    } else {
        self.contentView.backgroudColor= [UIColor white];
    }
}

#1


It seems that I have solve the problem. First set the :

看来我已经解决了这个问题。首先设置:

cell.selectionStyle = UITableViewCellSelectionStyleNone;

and the overwrite the method:

并覆盖方法:

- (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated
{
    if (highlighted) {
        self.contentView.backgroudColor= [UIColor gray];
    } else {
        self.contentView.backgroudColor= [UIColor white];
    }
}