From 2e97dd2ad3ed3a35fbd57bb36e5daac7453dfe03 Mon Sep 17 00:00:00 2001 From: Ivan Sein Date: Fri, 13 Sep 2024 15:27:24 +0200 Subject: [PATCH] Add pinch and pan gestures recognizers to zoomableView instead of contentView for a better zooming experience. Signed-off-by: Ivan Sein --- NextcloudTalk/NCZoomableView.swift | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/NextcloudTalk/NCZoomableView.swift b/NextcloudTalk/NCZoomableView.swift index 17025790..bf9c697f 100644 --- a/NextcloudTalk/NCZoomableView.swift +++ b/NextcloudTalk/NCZoomableView.swift @@ -44,11 +44,11 @@ import Foundation func initGestureRecognizers() { self.pinchGestureRecognizer = UIPinchGestureRecognizer(target: self, action: #selector(handlePinch(_:))) self.pinchGestureRecognizer?.delegate = self - self.contentView.addGestureRecognizer(self.pinchGestureRecognizer!) + self.addGestureRecognizer(self.pinchGestureRecognizer!) self.panGestureRecognizer = UIPanGestureRecognizer(target: self, action: #selector(handlePan(_:))) self.panGestureRecognizer?.delegate = self - self.contentView.addGestureRecognizer(self.panGestureRecognizer!) + self.addGestureRecognizer(self.panGestureRecognizer!) self.doubleTapGestureRecoginzer = UITapGestureRecognizer(target: self, action: #selector(handleDoubleTap(_:))) self.doubleTapGestureRecoginzer?.delegate = self @@ -58,11 +58,11 @@ import Foundation public func replaceContentView(_ newView: UIView) { if let pinchGestureRecognizer = self.pinchGestureRecognizer { - self.contentView.removeGestureRecognizer(pinchGestureRecognizer) + self.removeGestureRecognizer(pinchGestureRecognizer) } if let panGestureRecognizer = self.panGestureRecognizer { - self.contentView.removeGestureRecognizer(panGestureRecognizer) + self.removeGestureRecognizer(panGestureRecognizer) } if let doubleTapGestureRecoginzer = self.doubleTapGestureRecoginzer { @@ -79,12 +79,12 @@ import Foundation } func handlePinch(_ recognizer: UIPinchGestureRecognizer) { - self.zoomView(view: self.contentView, toPoint: recognizer.location(in: recognizer.view), usingScale: recognizer.scale) + self.zoomView(view: self.contentView, toPoint: recognizer.location(in: self.contentView), usingScale: recognizer.scale) recognizer.scale = 1 if recognizer.state == .ended { let bounds = self.contentView.bounds - let zoomedSize = recognizer.view!.frame.size + let zoomedSize = self.contentView.frame.size let aspectRatioContentViewSize = AVMakeRect(aspectRatio: self.contentViewSize, insideRect: bounds).size