我有這段代碼在我的mkmapview中刪除一個註釋(引腳)而不擦除我的藍點(userLocation)。問題是,它刪除了我添加的看似隨機數的引腳。當它通過IBAction被調用時,它將刪除前5個,然後再次單擊它將刪除下3個,然後是下2個,然後是最後一個。刪除Annotation一次刪除隨機數量的註釋
當我按下時,我需要它來刪除最新的引腳等。等等
for (int i = 0;
i < [mapView.annotations count];
i++
)
{ if ([[mapView.annotations objectAtIndex:i] isKindOfClass:[MyAnnotation class]])
{
[mapView removeAnnotation:[mapView.annotations objectAtIndex:i]];
}
}
繼奧萊Begermann的建議,這項工作\t for(int i = [mapView.annotations count] -1; i> = 0; i--) \t { \t \t [mapView removeAnnotation:[mapView.annotations objectAtIndex:i]]; \t} – 2010-08-26 17:05:12