UITableViewCell modifies the contents of it's contentView hierarchy when the cell is is highlighted (user touches down on the cell).
Two examples I've found to date:
It's as if there's some logic in the UITableView cell that inspects all views in the cell's hierarchy and modifies them according to a set of mysterious rules, then restores them back to normal once the cell is un-highlighted.
Can anyone explain what and why UITableViewCell is modifying (unexpectedly and in an undocumented fashion) in the contents of my custom table view cells?
Thanks!
The highlighting of the UITableViewCell is documented in the Apple docs as follows:
The highlighting affects the appearance of labels, image, and background. When the the highlighted state of a cell is set to YES, labels are drawn in their highlighted text color (default is white). The default value is is NO. If you set the highlighted state to YES through this property, the transition to the new state appearance is not animated. For animated highlighted-state transitions, see the setHighlighted:animated: method.
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.
This does not mention UIButtons, but this post is about how to prevent the button from going into the highlighted state when the cell does.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With