用于UIScrollView的iOS5 UITapRecognizer干扰按钮.怎么修?

我在UIScrollView中的UIView中有一堆UIButtons.我正在尝试在滚动视图中添加点按识别器.点击识别器会触发,但现在我的按钮都没有工作.

我知道在iOS5中,UIScrollView可以在完成之后以某种方式将触摸事件传递给控件层次结构.任何人都可以帮我弄清楚如何做到这一点?

解决方法

将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 Class Reference

A Boolean value affecting whether touches are
delivered to a view when a gesture is recognized.

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.

相关文章

UITabBarController 是 iOS 中用于管理和显示选项卡界面的一...
UITableView的重用机制避免了频繁创建和销毁单元格的开销,使...
Objective-C中,类的实例变量(instance variables)和属性(...
从内存管理的角度来看,block可以作为方法的传入参数是因为b...
WKWebView 是 iOS 开发中用于显示网页内容的组件,它是在 iO...
OC中常用的多线程编程技术: 1. NSThread NSThread是Objecti...