2011-12-19 5 views
2

나는 MKUserTrackingBarButtonItem이있는 MKMapView입니다. 사용자의 현재 위치는 Follow 또는 FollowWithHeading 모드에서만 표시해야합니다. 구현은 다음과 같습니다MKMapView에서 showsUserLocation의 비정상적인 동작

- (void)mapView:(MKMapView *)mapView 
didChangeUserTrackingMode:(MKUserTrackingMode)mode 
     animated:(BOOL)animated 
{ 
    [mapView setShowsUserLocation:(mode != MKUserTrackingModeNone)]; 
} 

setShowsUserLocation를 호출 내 코드에있는 유일한 장소입니다 그리고 그것은 MKUserTrackingBarButtonItem을 누를 때 예상대로 작동합니다.

지도를 드래그하여 UserTrackingMode을 변경하면이 문제가 발생합니다.이 경우 "파란색 점"주석이 의도 한대로 사라지지만 드래그가 끝나면 약 20 %의 경우 다시 나타납니다.

그런 다음지도의 showsUserLocation 속성을 테스트하면 "파란색 점"주석이 표시 되더라도 항상 NO로 설정됩니다.

이 문제를 해결하는 방법을 알고 있다면 매우 도움이 될 것입니다.

답변

1

끌기 중 특정 시간에 사용자 위치 업데이트가 나타나면 showsUserLocationNO인데도 didUpdateUserLocation 대리자 메서드가 여전히 실행되고 파란색 점이 다시 나타납니다.

이것은지도보기의 단점 인 것으로 보입니다. didUpdateUserLocation에서

토글 showsUserLocation지도보기의 내부 상태를 해결하기 위해 보인다 파란 점은 사라집니다 :

이 작동
-(void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation 
{ 
    if (!mapView.showsUserLocation) 
    { 
     mapView.showsUserLocation = YES; 
     mapView.showsUserLocation = NO; 
    } 
} 
+0

가, 감사합니다! – carton

관련 문제