我正在使用帶有許多註釋的MKMapView。一切都還好,直到我放大和縮小我的地圖。一些註釋的位置相互切換。有人知道爲什麼 這裏是我調用viewDidLoad從3個數組導入註釋的代碼:經度,緯度和photoFileName。 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];
}
一切OK加載,滾動和縮放工作。然而,當我放大mapview(大約5-10倍),然後再縮小到第一個尺寸,一些註釋位置被改變(見底部註釋)。 我不會在這裏發佈函數viewForAnnotation,因爲它沒有被調用,我只是放大/縮小它發生的事情。 http://cC8.upanh.com/27.800.35078007.mF80/1.pnghttp://cC9.upanh.com/27.800.35078008.AWG0/2.png
你確定viewForAnnotation:永遠不會被調用嗎?我認爲這可能是由重用annotationView引起的。 – ender
哦,你是對的。我再次查看viewForAnnotation函數後解決了問題。這裏是我的舊代碼: – toandk
也許你應該更新你的問題,並顯示你是如何修復它 – ender