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:
- Put a UIView in a cell’s contentView with a background color. That UIView’s background color is removed when the table cell is highlighted (it’s apparently set to have a clear background.)
- Put a UIButton in contentView. When the cell is highlighted, the button is also forced into the highlighted state.
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:
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.