을, 나는 목표는 당신이 showUserLocation = YES
와 userTrackingMode = MKUserTrackingModeFollow
와 MKMapView
를 사용할 때 얻을 깜박이는 파란색 점을 교체하는 것이라고 생각했다. 그래서 이미지 나 표준 핀으로 대체하는 방법을 보여주었습니다.
그러나 현재 위치를 나타내는 파란색 점이 아니라, 애니메이션이 중단되어 사용자가 이동하고지도에서 확대/축소 할 때 나타나고 사라지는 것이 밝혀졌습니다.
removeAnnotations
을 호출하고 모든 주석 (시스템에서 MKUserLocation
주석을 생성 한 것을 포함하여)을 제거하면이 동작을 보았습니다. showUserLocation
을 끈 다음 다시 켜면이 동작을 보았습니다.
OP는 이러한 상황 중 어느 것도 적용되지 않는다고 지적하지만 향후 독자에게는 이러한 문제가 발생할 수있는 몇 가지 고려 사항이 있습니다.
원래 대답은 :
가장 쉬운 대답은 확실히 컨트롤러가 MKMapView
에 대한 delegate
되어 있는지 확인 한 다음 MKUserLocation
을 감지하는 viewForAnnotation
을 정의하고, 당신이 원하는대로와 주석 뷰를 대체하는 것입니다. 당신이
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation
{
if ([annotation isKindOfClass:[MKUserLocation class]])
{
if ([annotation isKindOfClass:[MKUserLocation class]])
{
NSString *annotationIdentifier = @"userlocation";
MKAnnotationView *annotationView = [mapView dequeueReusableAnnotationViewWithIdentifier:annotationIdentifier];
if (annotationView)
{
annotationView.annotation = annotation;
}
else
{
annotationView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:annotationIdentifier];
}
return annotationView;
}
}
// again, if you had other annotation types, such as MKPointAnnotation,
// handle them here
if ([annotation isKindOfClass:[MKPointAnnotation class]])
{
...
}
return nil;
}
출처
2013-05-01 03:08:48
Rob
질문에 혼란이 있다고 생각합니다. 업데이트 된 원본 게시물을 참조하십시오. 나는 사용자의 "파란색 점"을 바꾸려고하지 않습니다. 나는 왜 그것이 계속 사라지는지 궁금해서지도가 스크롤되거나 확대 될 때마다 다시 애니메이션을 적용합니다. – JimmyJammed