Reputation: 2668
I have a few UIButtons
inside UITableViewCells
, and all of them are missing default tap animation, however if I long press - animation works. I've found some solutions, like setting type to .system
, showsTouchOnHighlight = true
, but none of them have helped. What is the problem here?
Upvotes: 0
Views: 823
Reputation: 399
For this problem you can add extension to UIButton and override some methods.
You can check my answer here
Upvotes: 0
Reputation: 77477
It's not a "problem" - it's by design.
When you have an object such as a button in a table view or scroll view or collection view, and you "touch" it, the system needs to know whether you are tapping the button or if you want to touch-and-drag to scroll the view that contains the button.
So, the table view (really, the "scroll view part" of the table view), waits to see if you drag your finger or not before it performs any actions.
If you want the button to respond immediately to a touch, you need to set
delaysContentTouches = false
on the containing scroll view(s).
If you search for uibutton inside uitableviewcell delaysContentTouches
you should find plenty of discussion on this topic, and various approaches to change the default behavior.
Upvotes: 5