2013-07-02 3 views
1

MapKit을 사용하고 있으며 정확한 문제가 있습니다. 내가 않도록 옆에 핀이 아닌 파란색 버튼을 볼 수 있습니다,이 코드에서MKMapViewDelegate를 설정하면 IOS에서 내 마커가 사라집니다.

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation { 
    static NSString *identifier = @"MyLocation"; 
    if ([annotation isKindOfClass:[MyLocation class]]) { 

     MKAnnotationView *annotationView = (MKAnnotationView *) [mymap_ios dequeueReusableAnnotationViewWithIdentifier:identifier]; 
     if (annotationView == nil) { 
      annotationView = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:identifier]; 
      annotationView.enabled = YES; 
      annotationView.canShowCallout = YES; 

     } else { 
      annotationView.annotation = annotation; 
     } 
     annotationView.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure]; 
     return annotationView; 
    } 

    return nil; 
} 

:

이 내 코드입니다. 이 작업을 잊어 버린 것 같습니다.

그러나이 값을 추가하면 마커가 전혀 표시되지 않습니다.

저를 도와 줄 수 있습니까?

답변

2

지도보기의 delegate을 설정하지 않으면 viewForAnnotation이 호출되지 않고 액세서리 버튼없이 기본 빨간색 핀이 만들어집니다. 당신이 delegate을 설정하면


, 그것은 당신의 viewForAnnotation 방법을 호출하지만 기본적으로 어떤 사전 설정된 이미지 또는보기가없는 일반 MKAnnotationView를 만드는 (그것은 빈입니다). 또한

MKPinAnnotationView *annotationView = (MKPinAnnotationView *) [mymap_ios ... 
    if (annotationView == nil) { 
     annotationView = [[MKPinAnnotationView alloc] init... 


이 주석 당신의있는 추가 개체를 확인하십시오 :


하나는 주석 뷰의 image이보기에 일부 내용을 추가 또는 단순히 MKPinAnnotationView 대신 MKAnnotationView의 생성 설정 MyLocation을 입력하면 액세서리 버튼이없는 일반 빨간색 핀으로 표시됩니다.

관련 문제