问题
So I have a main view that is a UIScrollView, and I add all of my elements (UIButtons, UITextFields, UILabels etc. etc.) to it.
The problem I am having, is that when I go to tap a button, the button will perform the action(s) that it is supposed to, however I will not see the pressed animation occur. I can only see the animation if I press and hold for about half a second.
I believe this has something to do with the fact that the UIScrollView seems to think I am trying to scroll at first, but I am not sure.
Any suggestions would be greatly appreciated, I want the button animation to occur instantly when I press it.
回答1:
This is most likely caused by the delaysContentTouches set to YES (the default). Per the UIScrollView documentation:
delaysContentTouches
A Boolean value that determines whether the scroll view delays the handling of touch-down gestures.
@property(nonatomic) BOOL delaysContentTouches
Discussion
If the value of this property is YES, the scroll view delays handling the touch-down gesture until it can determine if scrolling is the intent. If the value is NO , the scroll view immediately calls touchesShouldBegin:withEvent:inContentView:. The default value is YES.
Set this property to NO on your UIScrollView and the touches will be passed instantly to your elements.
来源:https://stackoverflow.com/questions/25088042/ios-button-tap-animation-in-uiscrollview