我在地圖視圖上有單個註釋。我可以通過編程選擇它,但是我點擊它沒有任何反應。你可以幫幫我嗎?有沒有人遇到類似的問題?這裏mehod用於建立anotations:無法選擇註釋?
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation
{
MKAnnotationView *aView = [mapView dequeueReusableAnnotationViewWithIdentifier:@"MapVC"];
if (!aView) {
aView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"MapVC"];
aView.canShowCallout = YES;
aView.draggable=YES;
aView.leftCalloutAccessoryView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 30, 30)];
// could put a rightCalloutAccessoryView here
}
aView.annotation = annotation;
[(UIImageView *)aView.leftCalloutAccessoryView setImage:nil];
return aView;
}
並把它們添加到地圖視圖:
- (void)updateMapView
{
if (self.mapView.annotations) [self.mapView removeAnnotations:self.mapView.annotations];
if (self.annotation) [self.mapView addAnnotation:self.annotation];
}
而且mehod反應以按壓註解:
- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)aView
{
NSLog(@"did select annotation");
}
順便說,方法[ self.mapView selectAnnotation:annotation]的作品,但沒有提出一個標註(我用斷點檢查它)。雖然只是記錄註釋不(通過斷點再次)。
您可能希望包含一些視圖圖像,或者提供一些代碼以顯示設置方式。至少沒有更多的細節,很難弄清楚發生了什麼。 – dasblinkenlight 2012-03-22 12:00:26
檢查地圖視圖的委託是否已設置,並且註釋的title屬性不是零或空白。 – Anna 2012-03-22 17:21:51
title是definetly不是零,我不能檢查它是否爲空。順便說一句 - 拖動似乎並沒有工作太多,忘了提及我沒有作爲一個財產的頭銜,這只是我的電話中的一種方法。希望這會證明有用。 – 2012-03-22 18:09:39