iOS - Button tap animation in UIScrollView

夙愿已清 提交于 2020-01-14 06:05:30

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!