From 351ca217a04d347cca63fc6a028ad11f8530f7ae Mon Sep 17 00:00:00 2001 From: Oleksii Kirizii Date: Mon, 8 Oct 2018 12:47:41 +0200 Subject: [PATCH] Fix detecting touches on devices with force touch support On devices with force touch increasing the pressure leads to touchesMoved callback which invalidated touch data required in touchesEnded to inform a delegate. After change coordinates are taken into account to detect if movement has really occured. --- FTCoreText/FTCoreTextView.m | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/FTCoreText/FTCoreTextView.m b/FTCoreText/FTCoreTextView.m index 3bce4c2..c61c0ce 100755 --- a/FTCoreText/FTCoreTextView.m +++ b/FTCoreText/FTCoreTextView.m @@ -1362,6 +1362,12 @@ - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { + UITouch *touch = [touches anyObject]; + CGPoint currentTouchPosition = [touch locationInView:touch.window]; + CGPoint oldTouchPosition = [touch previousLocationInView:touch.window]; + if (CGPointEqualToPoint(currentTouchPosition, oldTouchPosition)) { + return; + } _touchedData = nil; [_selectionsViews makeObjectsPerformSelector:@selector(removeFromSuperview)]; _selectionsViews = nil; @@ -1560,4 +1566,4 @@ + (NSData *)ftct_dataWithBase64EncodedString:(NSString *)string return outputLength? outputData: nil; } -@end \ No newline at end of file +@end