2012-08-31 4 views
2

사용자 정의 주석 핀이 긴 탭에서 기본 빨간색 핀으로 변경됩니다.mkmapview의 주석 핀에 대한 사용자 정의 이미지

- (MKAnnotationView *) mapView:(MKMapView *)mapingView viewForAnnotation:(id <MKAnnotation>) annotation { 
MKPinAnnotationView *annView = nil; 
     if(annotation != mapingView.userLocation) 
     { 

      static NSString *defaultPinID = kDEFAULTPINID; 
      annView = (MKPinAnnotationView *)[mapingView dequeueReusableAnnotationViewWithIdentifier:defaultPinID]; 
      if (annView == nil) 
      annView = [[MKPinAnnotationView alloc] 
              initWithAnnotation:annotation reuseIdentifier:defaultPinID] ; 


      annView.canShowCallout = YES; 
      annView.image = [UIImage imageNamed:@"icon.png"];//sets image for default pin 

} 
return annView; 
} 


- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKPinAnnotationView *)view 
    { 
     if ([[view.annotation title] isEqualToString:@"AnnotationTitle"]) { 

      view.image = [UIImage imageNamed:@"selected_IconImage.png"]; 
     } 
    } 

주석 핀을 만지기 만하면 선택한 이미지가 나타납니다. 핀 맞춤형 이미지를 길게 탭하면 기본 빨간색 핀으로 되돌아갑니다.

이 문제를 해결하는 방법은 무엇입니까?

답변

12

사용을 대신 MKPinAnnotationViewMKAnnotationView, 내가지도보기를 추측하고있어 그것은 작동

+0

감사합니다 (당신이 볼 핀 이미지입니다) 기본 이미지로 돌아갑니다 리셋의 일종을 수행합니다. –

관련 문제