【发布时间】:2017-10-14 17:09:52
【问题描述】:
我自定义了我的callOutView,创建了自己的AnnotationView theGreatAnnotationView,但我想在地图上保留标准的注释引脚。在这段代码中,我使用了自定义注释图像view?.image = annotation.image,但是当删除该行时,我的地图上没有注释。你能帮我解决这个问题吗?
func mapView(_ surroundingMapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {
var annoView: MKAnnotationView?
if annotation.isKind(of: MKUserLocation.self) {
return nil
}
var view = surroundingMapView.dequeueReusableAnnotationView(withIdentifier: "imageAnnotation")
if view == nil {
view = theGreatAnnotationView(annotation: annotation, reuseIdentifier: "imageAnnotation")
reuseIdentifier: "imageAnnotation")
view!.canShowCallout = false
}
let annotation = annotation as! Artwork
view?.image = annotation.image
view?.annotation = annotation
return view
}
【问题讨论】:
-
如果您想在地图上使用标准图钉而不是
image,您应该使用MKPinAnnotationView。
标签: swift mapkit mkannotationview