0

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?

cannyboy
  • 24,180
  • 40
  • 146
  • 252
  • duplicate of http://stackoverflow.com/questions/5842080/how-to-detect-a-circle-motion-with-uigesturerecognizer – albianto Apr 30 '11 at 16:09
  • not a dupe. I can detect a circle, but not on a map – cannyboy Apr 30 '11 at 16:21
  • that's an EXCELLENT user interface idea. You are to be congratulated. – Fattie Apr 30 '11 at 20:34
  • Actually, it's not perfect. The map has to be scrollable, so the map is dragged around in a circle before the gesture is triggered. And also, sometimes people might drag the map around with circular motion without meaning to drop a pin. In fact that's happening quite often when I'm testing it. – cannyboy Apr 30 '11 at 22:41
  • you're right that it will interact with scrolling, but quite simply **that is true of any gesture**. As a general UI idea, it's a great idea! Thank you!! – Fattie May 01 '11 at 12:04

3 Answers3

2

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.

Jason Cragun
  • 3,233
  • 1
  • 26
  • 27
1

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

Cyprian
  • 9,423
  • 4
  • 39
  • 73
0

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.

cannyboy
  • 24,180
  • 40
  • 146
  • 252