많은 주석이있는 MKMapView를 사용하고 있습니다. 지도를 확대하고 축소 할 때까지는 모든 것이 정상입니다. 일부 특수 효과의 위치가 서로 전환됩니다. 왜 그런지 알아? 다음은 viewDidLoad 다음에 호출하여 경위, 위도 및 photoFileName의 3 개 배열에서 주석을 가져 오는 코드입니다. photoFileName은 모든 주석의 사진 파일 이름을 포함하고, 경도 및 위도는 이들의 좌표를 포함합니다.확대 및 축소 후 MKMapview 주석이 잘못되었습니다.
for (int i=0; i<[longitudes count]; i++)
CLLocation* location = [[CLLocation alloc] initWithLatitude:[latitudes objectAtIndex:i]
longitude:[longitudes objectAtIndex:i]];
CSMapAnnotation* annotation = [[CSMapAnnotation alloc] initWithCoordinate:[location coordinate]
annotationType:CSMapAnnotationTypeImage
title:@"";
subtitle:@"";
// Set data for the annotation. This data is used for displaying annotation
[annotation setUserData:[photoFilename objectAtIndex:i]];
[_mapView addAnnotation:annotation];
[annotation release];
[currentLocation release];
}
모두 확인을로드 스크롤 일을 줌. 그러나지도 뷰를 확대 (약 5-10 배) 한 다음 처음 크기로 다시 축소하면 일부 주석 위치가 변경됩니다 (하단 주석 참조). viewForAnnotation 함수는 호출되지 않았으므로 여기에 게시하지 않습니다. 단지 확대/축소하고 있기 때문에 발생합니다. http://cC8.upanh.com/27.800.35078007.mF80/1.pnghttp://cC9.upanh.com/27.800.35078008.AWG0/2.png
확실히 viewForAnnotation :은 호출되지 않습니까? annotationViews를 다시 사용하면이 문제가 발생할 수 있다고 생각합니다. – ender
아, 네 말이 맞아. 나는 viewForAnnotation 함수를 다시 본 후에 문제를 해결했다. 여기 예전 코드가 있습니다 : – toandk
어쩌면 질문을 업데이트하고 그것을 어떻게 수정했는지 보여줄 수 있습니다 – ender