识别圆形手势来放下注释,如何检测圆形?
我发现一些代码可以检测视图中任意位置的圆形手势: http://iphonedevelopment.blogspot.com/2009/04/detecting-circle -gesture.html
它工作正常。
现在我想将其合并到地图视图中,以便用户可以绘制一个圆圈,并且地图图钉会掉落在所绘制圆圈的中间。如果我使用上面的代码对 UIView 进行子类化,并在其上粘贴地图,则上面的代码不起作用。 (除非我隐藏地图)。如果我将代码放在子类 MKMapView 中,它也不起作用。
有没有办法将圆圈识别器与地图结合起来?
I've found some code which detects a circle gesture anywhere in a view:
http://iphonedevelopment.blogspot.com/2009/04/detecting-circle-gesture.html
It works fine.
Now I want to incorporate it into a map view, so that the user can draw a circle, and a map pin gets dropped in the the middle of the drawn circle. The above code doesn't work if I subclass a UIView, with the code above, and stick a map on it. (unless I hide the map). Neither does it work if I put the code in a subclassed MKMapView.
Is there a way to incorporate the circle recogniser with a map?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我使用的解决方案是不子类化 MKMapView,而是使用组合。意思是,创建你的 UIViewController,添加你的 MKMapView,然后在其上添加另一个透明的。将您的手势添加到该视图中。确保在该视图中没有点击其他触摸,以便 MKMapView 继续响应。
a solution that I have used is to not subclass MKMapView, but to use composition instead. Meaning, create your UIViewController, add your MKMapView, and then add another transparent on top of that. Add your gestures to that view. Make sure no other touches are tapped in that view, so the MKMapView continues to respond.
我的猜测是子类 MKMapView 并在那里实现圆形手势识别器。
然后在子类的视图上画圆圈。
My guess would be to subclass MKMapView and implement your circle gesture recognizer there.
Then draw the circle on the view of your subclass.
回答我自己的问题:
此页面很有用: http://justinhoff.com/swipe-gesture- with-uiwebview/
对于上面的圆圈示例,我将 CircleView 设置为 UIGestureRecognizer 而不是视图。在该文件中用“self.view”更改了“self”的实例。然后我将其与滑动手势示例结合起来,确保将圆形手势识别器的委托设置为 self。
如果有人需要了解更多详细信息,请告诉我。
Answering my own question:
This page is useful: http://justinimhoff.com/swipe-gesture-with-uiwebview/
For the circle example above, I made CircleView a UIGestureRecognizer instead of a view.. changed instances of 'self' with 'self.view' within that file. Then I combined it with the swipe gesture example, making sure to set the delegate of my circle gesture recognizer to self.
If anyone needs to know more details, let me know.