iOS5 UITapRecognizer for UIScrollView interfering with buttons. How to fix?(用于 UIScrollView 的 iOS5 UITapRecognizer 干扰按钮.怎么修?)
问题描述
我在 UIScrollView
中的 UIView
中有一堆 UIButton
.我正在尝试将点击识别器添加到滚动视图.点击识别器触发,但现在我的按钮都不起作用.
I have a bunch of UIButton
s within a UIView
within a UIScrollView
. I'm trying to add a tap recognizer to the scroll view. The tap recognizer fires, but now none of my buttons work.
我知道在 iOS5 中,UIScrollView
可以在完成后以某种方式将触摸事件向下传递到控件层次结构.任何人都可以帮我弄清楚如何做到这一点?
I know that in iOS5, UIScrollView
can somehow pass a touch event down to the control hierarchy after being done with it. Anyone can help me figure out how to do this?
推荐答案
设置UIGestureRecognizer
属性cancelsTouchesInView
为NO.
UITapGestureRecognizer *singleTapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self
action:@selector(singleTap:)];
singleTapGestureRecognizer.numberOfTapsRequired = 1;
singleTapGestureRecognizer.enabled = YES;
singleTapGestureRecognizer.cancelsTouchesInView = NO;
[tapableView addGestureRecognizer:singleTapGestureRecognizer];
[singleTapGestureRecognizer release];
来自 UIGestureRecognizer 类参考
影响是否触摸的布尔值当手势被识别时传递到视图.
A Boolean value affecting whether touches are delivered to a view when a gesture is recognized.
当此属性为 YES(默认值)并且接收者识别其手势,该手势的触摸是未交付的未交付到视图和之前交付的触摸通过 touchesCancelled:withEvent: 消息被取消发送到风景.如果手势识别器无法识别其手势,或者如果此属性的值为 NO,视图接收所有触摸多点触控序列.
When this property is YES (the default) and the receiver recognizes its gesture, the touches of that gesture that are pending are not delivered to the view and previously delivered touches are cancelled through a touchesCancelled:withEvent: message sent to the view. If a gesture recognizer doesn’t recognize its gesture or if the value of this property is NO, the view receives all touches in the multi-touch sequence.
这篇关于用于 UIScrollView 的 iOS5 UITapRecognizer 干扰按钮.怎么修?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:用于 UIScrollView 的 iOS5 UITapRecognizer 干扰按钮.怎么
基础教程推荐
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01