我有这段代码在我的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