ios MkMapView 在触摸时放置一个图钉
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5182082/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
MkMapView drop a pin on touch
提问by botptr
I am struggling to unearth a standard way to drop a pin on a MkMapView based on a touch input. There probably isnt a standard way, but it is always worth asking. If I have to implement this myself is the best approach to add a Gesture Recogniser to pick up a tap on the map view.
我正在努力寻找一种基于触摸输入在 MkMapView 上放置图钉的标准方法。可能没有标准的方法,但总是值得一问。如果我要实现这一点我自己是添加一个手势识别器拿起地图视图上的一个水龙头的最佳方法。
回答by
Yes, you can use a UILongPressGestureRecognizer
to do this.
是的,您可以使用 aUILongPressGestureRecognizer
来执行此操作。
This previous answer of mine has details with sample code:
How to add a push pin to a MKMapView(IOS) when touching?
这以前我的答案和示例代码的详细信息:
如何将图钉添加到的MKMapView(IOS)触摸时?
To animate the drop, in viewForAnnotation
, return an MKPinAnnotationView
with animatesDrop
set to YES.
要动画放置,在 中viewForAnnotation
,将MKPinAnnotationView
withanimatesDrop
设置为 YES。
回答by Merky
I know that the Maps app has a separate button (under the curl of the map) that drops a pin. Hence that is kind of how I do it (though not under the map curl). I have not read anywhere that there is a standard but I have not read all 12,000 GB of documentation (ha ha). I would say to check out some of the "standard" apps like Maps and follow what they do just to be consistent. I know that typically a double tap zooms the map so I'm not sure that I would use that. Just my $0.02...
我知道地图应用程序有一个单独的按钮(在地图的卷曲下)可以放置一个大头针。因此,这就是我这样做的方式(尽管不在地图卷曲下)。我没有读过任何有标准的地方,但我没有读过所有 12,000 GB 的文档(哈哈)。我会说检查一些“标准”应用程序,如地图,并遵循他们所做的只是为了保持一致。我知道通常双击会缩放地图,所以我不确定我会使用它。只是我的 0.02 美元...