在触摸图上添加 mkannotation
我想在用户点击地图时向我的 mkmapview 添加 mkannotation,以便他们可以选择位置。
我读过有关拖放的内容,但如果您想移动到城市的另一个角落,这有点烦人,因为您必须一步一步移动图钉。
如何获取用户点击并将我的图钉移动到那里的坐标?
谢谢!
I want to add a mkannotation to my mkmapview when an user taps over the map so they can choose a location.
I've read about the drag&drop but that's a bit annoying if you want to move to the other corner of the city because you have to move step by step the pin.
How can I get the coordinate where a user taps and move my pin there?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用
UITapGestureRecognizer
获取CGPoint
和点击点的坐标。然后添加您的目标操作
Use
UITapGestureRecognizer
to get theCGPoint
and coordinate of tapped point.then add your target action
在 iOS 上3.2,您可以使用此代码片段:
它类似,但不要使用
UIGestureRecognizer
。希望这有帮助。
On ios < 3.2, you can use this snippet:
it's similar, but don't use
UIGestureRecognizer
.Hope this helps.