[英]UIGestureRecognizer - reset is never called
我正在创建自定义手势识别器。 问题在于,永远不会调用reset方法,因此我无法重置识别器的状态。 因此,它只能在第一次使用
@implementation TouchGestureRecognizer {
UIGestureRecognizerState mState;
}
-(UIGestureRecognizerState) state {
return mState;
}
-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
if( [touches count] == 1 ) {
mState = UIGestureRecognizerStateBegan;
}
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
if( [touches count] == 1 ) {
mState = UIGestureRecognizerStateChanged;
}
}
- (void)reset {
mState = UIGestureRecognizerStatePossible;
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
mState = UIGestureRecognizerStateRecognized;
}
@end
该文档指出:
将手势识别器状态设置为UIGestureRecognizerStateEnded或UIGestureRecognizerStateRecognized后,运行时将调用此方法。
看来这就是您在touchesEnded:
中所做的。 在此方法中放置一个断点,然后从那里获取它。
您必须将其写入.h文件中。
#import <UIKit/UIGestureRecognizerSubclass.h>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.