我在iOS中为距离大于200米的地方创建了警报功能。它确实弹出了。但是我想知道是否可以在与苹果ID相似的警报框中放入注释视图。我不知道该怎么做。我在下面附加了我的代码。
func creatAlert (title:String, message:String, locations: [[String : Any]]) {
let alert = UIAlertController(title: title, message: message, preferredStyle: UIAlertControllerStyle.alert)
alert .addAction(UIAlertAction(title: "Yes", style: UIAlertActionStyle.default, handler: { (action) in
alert.dismiss(animated: true, completion: nil)
print("Yes")
}))
alert.addAction(UIAlertAction(title: "No", style: UIAlertActionStyle.default, handler: { (action) in
alert.dismiss(animated: true, completion: nil)
print("No")
}))
alert.addAction(UIAlertAction(title: "", style: UIAlertActionStyle.default, handler: { (action) in
for location in locations {
let annotations = MKPointAnnotation()
annotations.title = location["title"] as? String
annotations.coordinate = CLLocationCoordinate2D(latitude: (location["latitude"] as? CLLocationDegrees)!, longitude: (location["longtitude"] as? CLLocationDegrees)!)
self.mapView.addAnnotation(annotations)
}
}))
self.present(alert, animated: true, completion: nil)
}