找到你要的答案

Q:Something wrong when I select UITableViewCell?

Q:不对的时候,我选择UITableViewCell?

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.

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.

answer1: 回答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];
    }
}

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

cell.selectionStyle = UITableViewCellSelectionStyleNone;

和覆盖方法:

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