Search code examples
swiftmkmapviewios10

MKPointAnnotation go to another view


I would like to know how can I go to another view when I tap title on MKPointAnnotation

func addPin(lat:Double, lng:Double) {
        let testPin = CLLocationCoordinate2D(latitude: lat, longitude: lng)
        let dropPin = MKPointAnnotation()
        dropPin.coordinate = testPin
        dropPin.title = "123456"
        mapView.addAnnotation(dropPin)
    }

I need to segue with identifier "More"


Solution

  • Please add this delegate method in your code and check it

    func mapView(mapView: MKMapView, didSelectAnnotationView view: MKAnnotationView){
      performSegue(withIdentifier: "PlaceDetail", sender: nil)
    }