CustomTapGestureRecognizer improvement

This commit is contained in:
True Zhuanjia
2024-06-17 22:56:55 +08:00
parent 115d540b7d
commit c3d44647f9
+6 -8
View File
@@ -10,6 +10,8 @@
#import <UIKit/UIGestureRecognizerSubclass.h>
#import "CustomTapGestureRecognizer.h"
// The most accurate & reliable tap gesture recognizer of iOS with almost 100% recoginition rate, instances of different numberOfTouchesRequired barely compete with each other. UITapGestureRecognizer of Apple API is just intractable.
// Known issue: not reliable in absolute touch mode, since it competes with 2 finger zoom-in & out gestures from original moonlight
@implementation CustomTapGestureRecognizer
static CGFloat screenHeightInPoints;
@@ -40,8 +42,11 @@ static CGFloat screenHeightInPoints;
- (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
// [super touchesEnded:touches withEvent:event];
if(_gestureCaptured && [[event allTouches] count] == [touches count]){
if ([[event allTouches] count] > _numberOfTouchesRequired) {
_gestureCaptured = false;
self.state = UIGestureRecognizerStateFailed;
} else if(_gestureCaptured && [[event allTouches] count] == [touches count]){
_gestureCaptured = false; //reset for next recognition
if((CACurrentMediaTime() - _gestureCapturedTime) < _tapDownTimeThreshold){
lowestTouchPointYCoord = 0.0; //reset for next recognition
self.state = UIGestureRecognizerStateRecognized;
@@ -49,11 +54,4 @@ static CGFloat screenHeightInPoints;
}
}
/*
+ (CGFloat)lowestTouchPointHeight{
@synchronized (self){
return self.lowestTouchPointHeight;
}
}*/
@end