我正在加载带有单个注释的 map View 。就像iphone中的“ map 应用”。我有一个搜索栏,它显示了图钉位置的地址,如 map 所示。现在我决定更改位置地址。我在搜索栏中键入一个新的地址位置。然后我的 map View 必须删除现有注释并添加新注释。现在,我正在添加新注释,但无法删除现有注释。如何删除现有注释?
最佳答案
首先,获取 map View 上的注释列表,然后移除不是当前用户位置的注释(即在MKUserLocation
类中)。
NSArray *annotations = [mapView annotations];
for (id annotation in annotations) {
if (annotation isKindOfClass:[MKUserLocation class]) {
continue;
}
[mapView removeAnnotation:annotation];
}
然后您可以正常添加新注释。
关于iphone - 删除现有注释并将新注释添加到 map View 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8284057/