如何删除某个注释图钉
我有一个应用程序,可以向地图视图添加注释点,如下所示:
annot = [[AnnotationDelegate alloc] init];
annot.coordinate = CLLocationCoordinate2DMake(lat,long);
annot.title = [NSString stringWithFormat:@"%d",id];
annot.subtitle = string;
[mapView addAnnotation: annot];
该代码块可以执行多次,因为我允许用户向地图视图添加任意数量的引脚。我的问题是,是否有办法修改它以便用户可以删除某个引脚?现在我似乎只能删除最近添加的一个。
希望有任何帮助,谢谢。
I've got an application that adds annotation points to a mapView like so:
annot = [[AnnotationDelegate alloc] init];
annot.coordinate = CLLocationCoordinate2DMake(lat,long);
annot.title = [NSString stringWithFormat:@"%d",id];
annot.subtitle = string;
[mapView addAnnotation: annot];
This block of code can be executed several times, as I allow the user to add as many pins as they'd like to the mapView. My question is, would there be a way to modify this so that the user could REMOVE a certain pin? Right now I can only seem to remove the one most recently added.
Would appreciate any help, thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只需使用以下命令删除注释
即可:假设您有某种形式的 UI 来使用户能够选择他们正在处理的用户界面?例如,您可能会遇到这样的场景:他们点击一个图钉来选择它,然后点击用户界面中其他位置的删除按钮来删除该图钉?您可以使用类似这样的东西来跟踪最后选择的一个;
您还可以实现
didDeselectAnnotationView
方法。一如既往,Apple 提供了大量文档
Just remove the annotation using
Presumably you have some form of UI to enable the user to choose which one they are dealing with? For example you could have a scenario where they tap a pin to select it, and then tap a delete button elsewhere in your UI to remove that pin? You could track which one was last selected using something a bit like this;
You can also implement the
didDeselectAnnotaionView
method as well.As always, there's copious documentation over at Apple