iOS - UIScrollView 中的按钮点击动画

标签 ios objective-c cocoa-touch uiscrollview

所以我有一个主视图,它是一个 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/

相关文章:

ios - ios中的多个搜索栏实现

cocoa - 如何更改 Interface Builder 中的启动窗口位置

iphone - UIStoryboardSegue 和 WebView

ios - 抖动错误: Getter not found : 'iMobileDevice' when trying to rebuild Flutter tool

iphone - 在 ViewDidLoad 上的按钮上应用动画

ios - 导航 Controller 左边缘滑动和后退按钮行为之间的差异

ios - 如何从NSData将图像保存在iOS设备上?

iphone - 如何在 iPhone 中实现 Facebook 集成的社交框架?

ios - 为什么我的本地通知没有出现在我的实际设备上? (iPhone 5C)

objective-c - 使用一个代码库构建多个应用程序的良好机制