CustomTapGestureRecognizer improvement
This commit is contained in:
1 parent
115d540b7d
commit
c3d44647f9
1 file changed
+6
-8
@@ -10,6 +10,8 @@
|
|||||||
#import <UIKit/UIGestureRecognizerSubclass.h>
|
#import <UIKit/UIGestureRecognizerSubclass.h>
|
||||||
#import "CustomTapGestureRecognizer.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
|
@implementation CustomTapGestureRecognizer
|
||||||
|
|
||||||
static CGFloat screenHeightInPoints;
|
static CGFloat screenHeightInPoints;
|
||||||
@@ -40,8 +42,11 @@ static CGFloat screenHeightInPoints;
|
|||||||
|
|
||||||
- (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
|
- (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
|
||||||
// [super touchesEnded:touches withEvent:event];
|
// [super touchesEnded:touches withEvent:event];
|
||||||
if(_gestureCaptured && [[event allTouches] count] == [touches count]){
|
if ([[event allTouches] count] > _numberOfTouchesRequired) {
|
||||||
_gestureCaptured = false;
|
_gestureCaptured = false;
|
||||||
|
self.state = UIGestureRecognizerStateFailed;
|
||||||
|
} else if(_gestureCaptured && [[event allTouches] count] == [touches count]){
|
||||||
|
_gestureCaptured = false; //reset for next recognition
|
||||||
if((CACurrentMediaTime() - _gestureCapturedTime) < _tapDownTimeThreshold){
|
if((CACurrentMediaTime() - _gestureCapturedTime) < _tapDownTimeThreshold){
|
||||||
lowestTouchPointYCoord = 0.0; //reset for next recognition
|
lowestTouchPointYCoord = 0.0; //reset for next recognition
|
||||||
self.state = UIGestureRecognizerStateRecognized;
|
self.state = UIGestureRecognizerStateRecognized;
|
||||||
@@ -49,11 +54,4 @@ static CGFloat screenHeightInPoints;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
+ (CGFloat)lowestTouchPointHeight{
|
|
||||||
@synchronized (self){
|
|
||||||
return self.lowestTouchPointHeight;
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
Reference in new issue
Block a user