From d225006ad65b9b5ec4a5b0d85e199f685cded22c Mon Sep 17 00:00:00 2001 From: NinaWie Date: Tue, 17 Oct 2023 21:22:40 +0200 Subject: [PATCH] implement didDeselect method to avoid direct segue --- PennyMe/ViewController.swift | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/PennyMe/ViewController.swift b/PennyMe/ViewController.swift index 789aaf0f..d951f008 100644 --- a/PennyMe/ViewController.swift +++ b/PennyMe/ViewController.swift @@ -497,6 +497,14 @@ extension ViewController: MKMapViewDelegate { let gesture = UITapGestureRecognizer(target: self, action: #selector(ViewController.calloutTapped)) view.addGestureRecognizer(gesture) } + + func mapView(_ mapView: MKMapView, didDeselect view: MKAnnotationView) { + if let gestureRecognizers = view.gestureRecognizers { + for gestureRecognizer in gestureRecognizers { + view.removeGestureRecognizer(gestureRecognizer) + } + } + } @objc func calloutTapped(sender:UITapGestureRecognizer) { guard let annotation = (sender.view as? MKAnnotationView)?.annotation else {return} @@ -526,9 +534,6 @@ extension ViewController: MKMapViewDelegate { let launchOptions = [MKLaunchOptionsDirectionsModeKey: MKLaunchOptionsDirectionsModeWalking] location.mapItem().openInMaps(launchOptions: launchOptions) } - else { - self.performSegue(withIdentifier: "ShowPinViewController", sender: nil) - } } }