gpt4 book ai didi

ios - 如何设置可拖动的 map 图钉

转载 作者:行者123 更新时间:2023-11-29 12:59:24 26 4
gpt4 key购买 nike

我正在开发一个包含 MapKit 的应用程序。当第一张 map 加载时,pin 将位于预定义的位置。而此时pin的draggable属性设置为NO。现在我想做这个..当用户按下按钮编辑时,它将允许用户拖动图钉。当用户拖动 pin 并将其定位到新位置时,它会显示用户 pin 位置名称和经纬度。

最佳答案

MKAnnotationView 公开了 draggable 属性,可以将其设置为允许拖动添加到 map View 的每个注释。

MKAnnotationView 的文档指出:

If YES, the associated annotation object must also implement the setCoordinate: method. The default value of this property is NO.

子类 MKAnnotationView 并实现 setCoordinate 方法。
然后在您的 mapView:viewForAnnotation: 方法中,将 draggable 属性设置为 YES

关于ios - 如何设置可拖动的 map 图钉,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20193931/

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