views:

153

answers:

1

Hi!

I have a UITableView fed from some arrays. When the user selects a specific row, for example row 3, i would like to add a checkmark and change the text color (not the selectedTextColor, that i have already managed) of that row to red. I would simultaneously like to change the text color of, for example row 5, to green. How can this be accomplished?

As you might understand, i am working on a prototype quiz app.

Cheers, Adam

A: 

Use the UITableViewCellDelegate and specifically the method:

- (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath

In this method check that the row about to be selected is one of the specific row that you want to change the text color for. To get the specific cell use cellForRowAtIndexPath and then change the color of the text by the textLabel property and its textColor property.

Don't forget to change back the color when the row is deselected by using the willDeselectRowAtIndexPath...

willcodejavaforfood
Thank you very much for the help, but if i want to make the change permanent, is it just a matter of not including the "willDeselectRowAtIndexPath" part?
Adam Persson
@Adam Persson - Yes just leave that part out. Did you manage to get it working?
willcodejavaforfood