是否有可能删除UIButton在UIScrollView中突出显示的状态的延迟? [英] Is it possible to remove the delay of UIButton's highlighted state inside a UIScrollView?

查看:78
本文介绍了是否有可能删除UIButton在UIScrollView中突出显示的状态的延迟?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到,当UIButton在UIScrollView(或表视图)内部被触发时,突出显示的状态略有延迟。否则,突出显示的状态几乎是瞬间的。

I have noticed a slight delay on the highlighted state of a UIButton when touched down if it is inside a UIScrollView (or a table view). Otherwise, the highlighted state is pretty much instantaneous.

我猜测这必须是按设计提供用户滚动的机会。但它似乎似乎按钮对我没有反应。是否有办法解决这个问题?

I surmise this must be by-design to provide a chance for user to scroll. But it just seems like the button is unresponsive to me. Is there a way to fix this?

推荐答案

确实,这是一个设计选择。它需要这个小时间来区分滚动(panGesture)和水龙头。如果您消除此延迟,那么如果他将手指放在按钮的顶部,用户将无法滚动,这不是好的用户体验。

Indeed, it's a design choice. It needs this small time to differentiate a scroll (panGesture) from a tap. If you eliminate this delay, then the user won't be able to scroll if he places the finger on top of the button, which is not good user experience.


因为滚动视图没有滚动条,所以它必须知道触摸是否发出意图滚动,而不是意图跟踪内容中的子视图。为了进行这种确定,它通过启动定时器来临时拦截触下事件,并且在定时器触发之前,查看触摸手指是否进行任何移动。如果定时器触发而位置没有显着变化,则滚动视图将跟踪事件发送到内容视图的已触摸子视图。

Because a scroll view has no scroll bars, it must know whether a touch signals an intent to scroll versus an intent to track a subview in the content. To make this determination, it temporarily intercepts a touch-down event by starting a timer and, before the timer fires, seeing if the touching finger makes any movement. If the timer fires without a significant change in position, the scroll view sends tracking events to the touched subview of the content view.

UIScrollView文档

我不建议禁用延迟,但如果你坚持,你可以在界面构建器(选择滚动视图,在右侧面板,在弹跳缩放下)或使用此代码设置:

I wouldn't recommend disabling the delay, but if you insist, you can set it in interface builder (select the Scroll View, and on the right panel, right under "Bounces Zoom"), or using this code:

scrollView.delaysContentTouches = false

这篇关于是否有可能删除UIButton在UIScrollView中突出显示的状态的延迟?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆