所以我有一个主视图,它是一个 UIScrollView,我将所有元素(UIButtons、UITextFields、UILabels 等)添加到它。
我遇到的问题是,当我点击一个按钮时,该按钮将执行它应该执行的操作,但是我不会看到按下的动画发生。 我只有按住大约半秒才能看到动画。
我相信这与 UIScrollView 一开始似乎认为我正在尝试滚动这一事实有关,但我不确定。
如有任何建议,我将不胜感激,我希望按钮动画在我按下时立即出现。
最佳答案
这很可能是由于 delaysContentTouches 设置为 YES(默认值)引起的。根据 UIScrollView 文档:
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.
在您的 UIScrollView 上将此属性设置为 NO,触摸将立即传递到您的元素。
关于iOS - UIScrollView 中的按钮点击动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25088042/