Recognising a circle gesture to drop an annotation, how to detect circle?

佐手、 提交于 2019-12-06 17:17:41

问题


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?


回答1:


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.




回答2:


My guess would be to subclass MKMapView and implement your circle gesture recognizer there. Then draw the circle on the view of your subclass.




回答3:


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.



来源:https://stackoverflow.com/questions/5842892/recognising-a-circle-gesture-to-drop-an-annotation-how-to-detect-circle

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!