我試圖爲我的地圖上的註釋創建自定義的註釋。我這樣做是通過調整協議MKMapViewDelegate
並覆蓋功能mapView:viewForAnnotation:
。這一切正常,唯一的問題是我也有showsUserLocation
設置爲TRUE
,這意味着我在我的mapView:viewForAnnotation:
方法中得到的一個「註釋」是類MKUserLocation
。mkmapview MKUserLocation AnnotationView
我不希望userlocation註釋具有我的自定義annotationview,我希望那個顯示默認的userlocation annotationview!如何返回用戶位置的默認userlocation註釋視圖或將其從註釋中排除(該註釋來自mapView:viewForAnnotation:
)?
我試圖捕捉mapView:viewForAnnotation:
方法中的UserLocation,但我不知道該返回什麼! (在這個例子中,我返回一個標準MKAnnotationView,但並不像默認的用戶位置註釋(顯然)。)
if (![[annotation class] isEqual:[MKUserLocation class]]) {
MKAnnotationView *view = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"customAnnotation"];
// edit the custom view
return view;
}
MKAnnotationView *view = [[MKAnnotationView alloc] init];
return view;
請寫出您在圖形頁面已經實現代碼:viewForAnnotation – Pratik 2013-03-19 08:55:29