[英]ios gesture recognizer for all types
我只需要知道是否有办法在一个UIGestureRecognizer实例中捕获所有类型的手势。
示例:我有一个UIView,我必须检测它上面的任何类型的点击,而不为每种类型的手势创建一个实例
有没有办法做到这一点 ?
谢谢,
当然,它是自己处理低级UIView事件( iOS事件处理指南 ):
Responding to Touch Events
– touchesBegan:withEvent:
– touchesMoved:withEvent:
– touchesEnded:withEvent:
– touchesCancelled:withEvent:
Responding to Motion Events
– motionBegan:withEvent:
– motionEnded:withEvent:
– motionCancelled:withEvent:
您可以UIGestureRecognizer
类,并在触摸开始时将其内部状态更改为UIGestureRecognizerStateRecognized
。
示例代码:
@interface UITouchGestureRecognizer : UIGestureRecognizer
@end
#import <UIKit/UIGestureRecognizerSubclass.h>
@implementation UITouchGestureRecognizer
- (void) reset
{
[super reset];
}
- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
[super touchesBegan:touches withEvent:event];
self.state = UIGestureRecognizerStateRecognized;
}
@end
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.