UITapGestureRecognizer 正在覆盖 Scrollview 上的 UIButton 操作 [英] UITapGestureRecognizer is overriding UIButton actions on Scrollview

查看:33
本文介绍了UITapGestureRecognizer 正在覆盖 Scrollview 上的 UIButton 操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有按钮的滚动视图.我有一个设置为 TouchupInside 的操作.最初工作正常.所以我需要 Scrollview 如果它在 3 秒内没有被触摸过就会自动隐藏.为此,我在 Scrollview 上使用了 UITapGestureRecognizer.如果您触摸 Scrollview 中的任何位置,它肯定会起作用.不幸的是 UIButton 不再有效.UITapGestureRecognizer 似乎取代了按钮.

I have a Scrollview with a button on it. I have an action set to TouchupInside. Works fine initially. So I need the Scrollview will autohide if it hasnt been touched in 3 seconds. To accomplish this i am using UITapGestureRecognizer on the Scrollview. It definitely works if you touch anywhere in the Scrollview. Unfortunately the UIButton no longer works. The UITapGestureRecognizer seems to supersede the button.

任何想法如何让 UIButton 操作工作?

Any ideas how to get the UIButton Action to work?

推荐答案

您可以使用此行阻止 UITapGestureRecognizer 取消其他事件:

You can stop the UITapGestureRecognizer from cancelling other events using this line:

tapRecognizer.cancelsTouchesInView = NO;

为我工作:)

这篇关于UITapGestureRecognizer 正在覆盖 Scrollview 上的 UIButton 操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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