What is the difference between a highlighted UITableViewCell and a selected UITableViewCell?

A UITableViewCell reflects two distinct states: Highlighted and Selected.

For me, they sound identical so what exactly are the differences?


Solution 1:

Highlight happens on touch down.

Selected happens on touch up, followed by the call to didSelectRowAtIndexPath:. In a standard UITableView, there is usually a small delay between the highlight and the select.

Solution 2:

From appearance point of view:

Selected Cell:

The selection affects the appearance of labels, image, and background. When the selected state of a cell is set to YES, it draws the background for selected cells with its title in white.

The background will be drawn based on selectionStyle & selectedBackgroundView values. I could not really see any white titles as Apple documentation mentioned. I just see the background changes as expected.

Highlighted Cell:

The highlighting affects the appearance of labels, image, and background. When the highlighted state of a cell is set to YES, labels are drawn in their highlighted text color (default is white). Note that for highlighting to work properly, you must fetch the cell’s labels using the textLabel and detailTextLabel properties and set each label’s highlightedTextColor property; for images, get the cell’s image using the imageView property and set the UIImageView object’s highlightedImage property.

Again I don't really that see that the default highlighted text color is white.

So I conclude that selected cell appearance affects the background of the cell while the highlighted cell affects the labels text colors as well as the image (if highlightedImage property is set)