我在字典中有 POI:
["_id": "12345ACB", "title": "Some Shop Place", "category": "Shop", "latitude": 12.345677, "longitude": 21.12348], ...
我有添加注释的功能:
func addPlaces() {
for poi in pois {
let pin = MKPointAnnotation()
if let loc = poi["location"] as? NSDictionary {
pin.coordinate = CLLocationCoordinate2D(latitude: (loc["lat"] as? Double)!, longitude: (loc["lng"] as? Double)!)
}
if let cat = poi["_category"] as? NSDictionary {
pin.subtitle = cat["name"] as? String
}
pin.title = poi["title"] as? String
mapView.addAnnotation(pin)
}
}
还有一个标注功能:
func mapView(_ mapView: MKMapView, annotationView view: MKAnnotationView, calloutAccessoryControlTapped control: UIControl) {
let info = view.annotation
let placeName = info?.title
let placeInfo = info?.subtitle
let ac = UIAlertController(title: placeName!, message: placeInfo!, preferredStyle: .actionSheet)
ac.addAction(UIAlertAction(title: "Open", style: .default, handler: { (UIAlertAction) in
// Here I need POI's _ID
self.performSegue(withIdentifier: "DealsSegue", sender: self)
}))
present(ac, animated: true)
}
那么,在警报行动中,我需要 POI 字典中的 _id 来获取特定(点击)引脚吗?
谢谢