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 に答える