last day (14 days later) » 

09:31
1
A: Swift. Change Color of Custom Tableview Cell Label when selected

Shamas SYou just need to translate the same code to Swift. var myCell = tableView.cellForRowAtIndexPath(indexPath) as! MPSurveyTableViewCell myCell.customLabel.textColor = UIColor.redColor()

by this solution, if I clicked on many cells, all cells will be red ? or only the selected one will be red, and the others will back to the essential color?
I think all selected cells will be red, but if you are reusing cells, inconsistent behaviour will appear.
thanks :) but do you now how to make the other cells take the essential color? Really all the selected cells are red, and didn't back to the essential color after select other cells :S
If you are playing between 2 cells only, then you can keep indexPath as a class variable. Each time a cell is selected, you get previous cell with savedIndexPath, unselect its color, get newer cell and select its color and save the new indexPath.
upvote if it works for you :D
no not 2 cells @_@ i'm working on tableview with number of cell unknown for me :S
09:31
hi
I meant if at a time you only want to keep one cell selected, then you can keep indexPath of last selected cell on class level
and then on every other cell clicked, you can unselect the last cell, click the new one and save it's indexPath
hey :)
how can i "unselect the last cell"?
how do you select the new cell?
on didSelect delegate
09:49
yeah so what do you do in that fucntion?
do you select a color/
or does it just automaticlally select the grey color?
if you select something yourself
when new cell is selected, you should find the previous cell and unselect its color
otherwise just call deselectCellAtIndexPath and give it previous indexPath
10:06
hey :)
in Didselect delegate, i write the following code:

let cell = tableView.cellForRowAtIndexPath(indexPath) as! FaqTableViewCell
cell.faqLabel.textColor = UIColor.redColor()
oh got you
Thanks ^_^

last day (14 days later) »