Skip to content

Commit

Permalink
implement didDeselect method to avoid direct segue (#180)
Browse files Browse the repository at this point in the history
  • Loading branch information
NinaWie authored Oct 17, 2023
1 parent 35cf233 commit 07d7da0
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions PennyMe/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -526,9 +534,6 @@ extension ViewController: MKMapViewDelegate {
let launchOptions = [MKLaunchOptionsDirectionsModeKey: MKLaunchOptionsDirectionsModeWalking]
location.mapItem().openInMaps(launchOptions: launchOptions)
}
else {
self.performSegue(withIdentifier: "ShowPinViewController", sender: nil)
}
}
}

Expand Down

0 comments on commit 07d7da0

Please sign in to comment.