2010-02-09 4 views
6

MKMapView를 사용하면 주석이 많이로드되어 세그먼트 컨트롤로 표시된 주석을 필터링 할 수 있기를 원합니다.지도 주석을 삭제하지 않고 숨기기

유형 변수를 사용하여 맞춤식 특수 효과를 사용하고 있으므로 서로 구분할 수 있지만 주석보기의 하위 집합을 숨기고 표시 할 수있는 방법을 찾지 못했습니다.

답변

8

물론,이 시도 :

목표 - C 솔루션 :

[[yourMapView viewForAnnotation:yourAnnotation] setHidden:YES] 

스위프트 4 솔루션 :

yourMapView.view(for: yourAnnotation)?.isHidden = true 

이 당신에게 지정과 관련된 뷰를 반환합니다 그러면 뷰를 숨김으로 설정할 수 있습니다. 다음은 documentation입니다. 당신은 사용자 정의 하나 만들 수 MKAnnotationView (거품)을 숨기려면

+0

감사, 치료를했다. 이 일로 빨리 돌아 가지 않아서 죄송합니다. – Affian

+0

np ... 도움이 되니 기쁩니다! –

+0

필터링 할 때 주석을 숨기거나 제거하는 것이 더 좋습니다. – lostintranslation

0

: 그에 대한

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation 
{ 

    if (annotation==self.map.mapView.userLocation) 
     return nil; 


    MKAnnotationView *annotationView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"loc"]; 
    if([annotation isKindOfClass:[AnnotationCustomClass class]]) { 
     annotationView.canShowCallout = NO; // <- hide the bubble 

    } 

    return annotationView; 

} 
관련 문제