问题
I put a UIButton
on a UITableViewCell
and set its showsTouchWhenHighlighted
property to YES
. The cell's selection style is UITableViewCellSelectionStyleNone
. I have a selector that gets called when the button is tapped and it's working fine, so the button is getting the touch events fine. However, button doesn't show the highlight effect when touched.
When I put this button on a UIView
, the highlight effect works.
How can I make this work when the button is placed on the cell?
回答1:
Are you adding the button to the cell or cell.contentView? The contentView property behaves more like a regular UIView, that might solve your problem.
回答2:
You need to set 'delaysContentTouches' to NO on the Table View
来源:https://stackoverflow.com/questions/14756792/why-doesnt-uibutton-showstouchwhenhighlighted-work-when-the-button-is-on-a-uita