如何删除所有注释引脚然后添加一个新注释引脚

时间:2012-10-24 22:12:54

标签: ios annotations mkmapview

好奇,如果有人可以帮忙做一件事:

我只是试图告诉Xcode,如果地图上同时存在“addAnnotation”和“newAnnotation”引脚,则删除初始的“newAnnotation”引脚。

我的非工作代码如下:

if ([self.mapView addAnnotation:addAnnotation] & [self.mapView addAnnotation:newAnnotation] return)
{
    [self.mapView removeAnnotation:newAnnotation];
}

谢谢!

1 个答案:

答案 0 :(得分:6)

感谢您的反馈,但我解决了这个问题:

NSArray *existingpoints = mapView.annotations;

if ([existingpoints count])
    [mapView removeAnnotations:existingpoints];
相关问题