我正在创建自定义手势识别器。问题是从不调用重置方法,所以我无法重置识别器的状态。结果它只第一次工作
@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