0

我有一个带有自定义单元格的表格视图,我已将单元格设置为当您点击它时在文本上突出显示颜色。

//特定于单元格

NSString *ligneTableau = [NSString stringWithFormat:@"%@", [[table objectAtIndex:indexPath.row] nome]];
cell.label.text = ligneTableau;  
cell.label.font = [UIFont fontWithName:@"populaire" size:35];
cell.label.textColor = [UIColor colorWithRed:124.0f/255.0f green:153.0f/255.0f blue:106.0f/255.0f alpha:1.0f];
cell.fondo.image = [UIImage imageNamed: @"cell_ant.png"];    

//highlighted Text

cell.label.highlightedTextColor = [UIColor colorWithRed:55.0f/255.0f green:70.0f/255.0f blue:48.0f/255.0f alpha:1.0f];

一切正常,但是当回到表格时,文本保持突出显示。

我忘记了什么?

4

2 回答 2

0

在您的UpdatesTableViewCell课程中,您可以实现以下方法:

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

    if (highlighted)
        self.label.textColor = [UIColor colorWithRed:55.0f/255.0f green:70.0f/255.0f blue:48.0f/255.0f alpha:1.0f];
    else
        self.label.textColor = [UIColor colorWithRed:124.0f/255.0f green:153.0f/255.0f blue:106.0f/255.0f alpha:1.0f];
}

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

    if (selected)
        self.label.textColor = [UIColor colorWithRed:55.0f/255.0f green:70.0f/255.0f blue:48.0f/255.0f alpha:1.0f];
    else
        self.label.textColor = [UIColor colorWithRed:124.0f/255.0f green:153.0f/255.0f blue:106.0f/255.0f alpha:1.0f];
}
于 2012-04-17T13:18:50.250 回答
0

当您返回表格时,可能该单元格仍处于选中状态。因此,一旦回到表中,您应该设置取消选择。

    [cell setSelected:NO];
于 2012-04-17T07:35:47.113 回答