2014-04-25 3 views
1

가끔씩 겹치는 일부 경로가있는 MKMapView가 있으며보기 앞에서 특정 경로를 가져 오려고합니다. 나는 이것을 시도하고 있지만 작동하지 않는 것 같습니다 :MKPolylineView를 앞에 가져올 수 없습니다.

[[polylineViewZoom superview] bringSubviewToFront:polylineViewZoom]; 

polylineViewZoom is a MKPolylineView. 

미리 감사드립니다!

답변

0

그냥 오버레이 배열에서 제거 전면에 폴리 라인을 가지고하고자하는 경우 그 다음이

[mapView addOverlay:polyline level:MKOverlayLevelAboveRoads]; 

처럼 할 수 iOS7에있는 경우 대신

[mapView addOverlay:polyline level:MKOverlayLevelAboveLabels]; 
+0

고맙습니다. Panayot, 제거/다시 추가 솔루션을 피하려고합니다. 그래서 bringSubviewToFront 선택기를 사용하려고했습니다. – MAG

1

처럼 다시 추가 MKPolylineViewsuperview에 직접 액세스하려면 MKMapView 클래스에서 제공하는 insertOverlay:atIndex: 메소드를 사용하십시오.

insertOverlay:atIndex: 방법은 이미가보기/디스플레이 계층 (addOverlay 또는 addOverlays 사용) 맵에 추가 된 을 가진 오버레이를 옮긴다. "위치 변경"을 통해 오버레이의 좌표가 바뀌는 것을 의미하지는 않습니다. 단지 z- 인덱스가 다른 오버레이와 겹치도록 제어한다는 것입니다.

는이 방법 (하지MKOverlayView 또는 MKOverlayRenderer)에 id<MKOverlay> 객체를 전달합니다. 지도보기는 내부적으로 필요에 따라보기 또는 레이어를 조작합니다.

이 방법은 index 파라미터 7.

을 모두 아이폰 OS 6 일 및 iOS 것는 0 값에있을 것이다 뷰 계층의 "바닥"과 가장 index에 오버레이 수단 " 위쪽 "또는"앞 "으로 표시됩니다.

지도에 5 개의 오버레이가 추가 된 경우 index 범위는 0-4이며 오버레이의 index을 4로 설정하면 앞에 오버레이가 표시됩니다.

예 :

//Somewhere earlier, you add the overlay to the map view using 
//addOverlay or addOverlays. 

//... 

//Later, when you want to bring an overlay to the front, get a reference 
//to the overlay either from the map view's overlays array 
//or you might keep a reference to it in an instance variable. 
id<MKOverlay> someOverlay = ...; 

//calculate index for the last ("top") overlay... 
NSUInteger maxIndex = self.mapView.overlays.count - 1; 

[self.mapView insertOverlay:someOverlay atIndex:maxIndex]; 

주 대신 유용하게 사용할 수있는 오버레이 계층 구조 (예 : exchangeOverlay:withOverlay:, insertOverlay:aboveOverlay:, 등.) 변경에 관한 몇 가지 다른 방법이 있습니다. 자세한 내용은 MKMapView 클래스 참조를 참조하십시오.

관련 문제