Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIButton in UITableViewCell doesn't highlight on tap

The Problem: When a user taps on a UIButton in a UITableViewCell, the button will only highlight on a long tap, not on a quick tap. The desired behaviour for this button to highlight regardless of the tap duration.

Unfortunately: Setting delaysContentTouches to NO on any UIScrollView or UITableView is not an option because of other undesired side effects.

So: How can I get around this - is there a way to forward touches to the button, bypassing the delaysContentTouches value?

like image 810
Jordan Smith Avatar asked Feb 11 '14 23:02

Jordan Smith


1 Answers

just set delayContentTouches = false to whatever scrollview you're using (UITableView or UICollectionView). That should do it.

As the doc says:

A Boolean value that determines whether the scroll view delays the handling of touch-down gestures. If the value of this property is true, the scroll view delays handling the touch-down gesture until it can determine if scrolling is the intent. If the value is false , the scroll view immediately calls touchesShouldBegin(_:with:in:). The default value is true.

like image 177
facumenzella Avatar answered Oct 13 '22 22:10

facumenzella