【发布时间】:2019-05-29 07:47:15
【问题描述】:
我尝试使用 func mapView(_ mapView: MKMapView, didSelect view: MKAnnotationView) 将注释标题传递给嵌入式容器视图。但是,当我构建并运行时,它不起作用。
我做错了什么?这是正确的方法吗?
我试过 func mapView(_ mapView: MKMapView, didSelect view: MKAnnotationView) 查看代码
var annotationTitle = "Default"
func mapView(_ mapView: MKMapView, didSelect view: MKAnnotationView){
if let annotation = view.annotation {
annotationTitle = annotation.title!!
}
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "showMapContainer" {
let destination = segue.destination as! MapDetailContainerViewController
destination.selectedAnnotation = annotationTitle as String
}
}
}
数据作为“Deafult”而不是 annotation.title 值传递给 containerviewcontroller
【问题讨论】:
-
感谢您的洞察力。容器和地图同时显示。我希望能够单击各种地图图钉并让容器显示有关当前选择的图钉的信息。
标签: swift xcode mkannotationview