gpt4 book ai didi

iphone - 删除现有注释并将新注释添加到 map View 中

转载 作者:可可西里 更新时间:2023-11-01 03:48:03 25 4
gpt4 key购买 nike

我正在加载带有单个注释的 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com