我正在尝试制作一个自定义的注解。我创建了一个定制的注解类,在其中我设计了注解视图。我正在尝试调用我的视图控制器中的viewForAnnotation中的类。当我运行应用程序时,它会向我显示基本视图。下面是函数。如果您也想查看自定义注释类,请让我知道。
func mapView(mapView: MKMapView, viewForAnnotation annotation: MKAnnotation) -> MKAnnotationView? {
let reuseIdentifier = "CustomAnnotation"
if (annotation.isKindOfClass(CustomAnnotation)) {
var annotationView = mapView.dequeueReusableAnnotationViewWithIdentifier(reuseIdentifier) as! CustomAnnotation!
annotationView = CustomAnnotation(annotation: annotation, reuseIdentifier: reuseIdentifier)
return annotationView
}
else {
return nil
}
}发布于 2016-09-05 14:21:18
函数注释(mapView: MKMapView,viewForAnnotation annotation: MKAnnotation) -> MKAnnotationView?{ if annotation is MKUserLocation { return nil }
let reuseId = "pin"
var pinView = mapView.dequeueReusableAnnotationViewWithIdentifier(reuseId) as? MKPinAnnotationView
if pinView == nil {
pinView = MKPinAnnotationView(annotation: annotation, reuseIdentifier: reuseId)
pinView?.animatesDrop = true
pinView?.canShowCallout = false
pinView?.draggable = true
}
else {
}
return pinView
}https://stackoverflow.com/questions/39316153
复制相似问题