UITableViewCell setSelected method color text label black

Does anyone else experience this problem if, if you programmatically set the selected state of UITableViewCell to YES, does it color the text label black?

[cell setSelected: YES]

I can’t figure it out. I would expect him to highlight the blue cell. Manual cell selection works because it colors the blue cell while the text is displayed in white.

Any help is appreciated. Thanks in advance!

+4
source share
1 answer

I had the same problem and fixed it by moving cell.selected = YES to tableView: willDisplayCell: forRowAtIndexPath .

I think this may be due to a note at the bottom of the UITableViewCell documentation about background color changes requiring the use of tableView: willDisplayCell: forRowAtIndexPath (supposedly selected sets the background color).

+6
source

Source: https://habr.com/ru/post/1334316/


All Articles