1
我試圖做一個自定義註釋。我做了一個自定義註記類,在那裏我設計了註解視圖。我試圖在ViewController的viewForAnnotation中調用這個類。當我運行該應用程序時,它會向我顯示基本視圖。這是功能。讓我知道你是否也想看到自定義註記類。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
}
}
對我來說,它看起來像你混淆了術語'annotation'和'annotationview'。你設置了一個自定義的'annotation',但是嘗試將它用作'annotationview'(參見函數簽名:'MKAnnotation'!='MKAnnotationView')。 –
我必須解決什麼問題? – jonask
你想如何在mapview上顯示你的註解? –