MKPointAnnotation 转到另一个视图

MKPointAnnotation go to another view

我想知道点击标题时如何转到另一个视图 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)
    }

我需要使用标识符进行搜索 "More"

您需要从 MKMapViewDelegate:

覆盖此方法
func mapView(_ mapView: MKMapView, annotationView view: MKAnnotationView, calloutAccessoryControlTapped control: UIControl) {
    performSegue(withIdentifier: "PlaceDetail", sender: nil)
}

请在您的代码中添加此委托方法并进行检查

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