views:

40

answers:

1

When my user clicks on a cell I want the text to turn white:

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {

    [super setSelected:selected animated:animated];
    lblName.textColor = [UIColor whiteColor]; 
    lblTime.textColor = [UIColor whiteColor];
}

This works fine, but when the user selects another cell, the previous cell's text color remains white. How can I revert it back to black?

A: 
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSIndexPath *oldIndexPath;

    UITableViewCell *cell1 = [tableView cellForRowAtIndexPath:indexPath];
    UITableViewCell *cell2 = [tableView cellForRowAtIndexPath:oldIndexPath];
    cell1.textLabel.textColor = [UIColor whiteColor];
    cell2.textLabel.textColor = [UIColor blackColor];

    oldIndexPath = indexPath;
}
Kurbz