From 850332b5a1a4bd5ee4356f1234afcec53e21ebcb Mon Sep 17 00:00:00 2001 From: "Scott Corscadden (Morgiij)" Date: Tue, 7 Nov 2017 13:40:43 -0500 Subject: [PATCH] Work around #76: Don't draw/annotate unless only one finger is used --- .../Annotations/PDFAnnotationController.swift | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Pod/Classes/Annotations/PDFAnnotationController.swift b/Pod/Classes/Annotations/PDFAnnotationController.swift index e0cd2b0..fcf12d3 100644 --- a/Pod/Classes/Annotations/PDFAnnotationController.swift +++ b/Pod/Classes/Annotations/PDFAnnotationController.swift @@ -231,7 +231,13 @@ open class PDFAnnotationController: UIViewController { //MARK: - Touches methods to pass to annotation open override func touchesBegan(_ touches: Set, with event: UIEvent?) { - guard let touch = touches.first else { return } + // We only allow one-finger touches to start annotations, as otherwise + // when you are pen-editing then try to zoom, one of your fingers will draw instead of zooming + // This is a HACK, as IDEALLY the two-finger pinch would zoom while still in + // annotation editing mode, but for the life of me I could not get that to go, forwarding + // events/touches to pretty much anything. + guard let touch = touches.first, event?.allTouches?.count == 1 + else { return } let page = annotationDelegate?.annotationWillStart(touch: touch) @@ -252,14 +258,16 @@ open class PDFAnnotationController: UIViewController { open override func touchesMoved(_ touches: Set, with event: UIEvent?) { - guard let touch = touches.first else { return } + guard let touch = touches.first, event?.allTouches?.count == 1 + else { return } let point = touch.location(in: pageView) currentAnnotation?.touchMoved(touch, point: point) } open override func touchesEnded(_ touches: Set, with event: UIEvent?) { - guard let touch = touches.first else { return } + guard let touch = touches.first, event?.allTouches?.count == 1 + else { return } let point = touch.location(in: pageView) currentAnnotation?.touchEnded(touch, point: point)