1

I am creating a MKMapView with some AnnotationViews with CalloutBubbles and so on. Now I want to add a UITapGestureRecognizer to show the mapview in fullscreen mode like it's well done in the Maps App from Apple. I have still created the code to hide the NavigationBarItems, etc. and it works well but my problem is that the tap gesture is still in use for selecting the annotations. So every time I want to touch the PinView, make a doubleTap, etc. my code is executed and the mapview goes into fullscreen instead of opening the calloutBubble, zoom, etc.

Here is my question. Is there a possibility to separate between taps in the background of the MKMapView and taps on the pins?

EDIT

When I use the - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer function and make a single tap on a annotation pin of my mapview I log this descriptions:

2014-02-24 15:27:31.257 MyApplication [807:70b] ; target= <(action=MySetFullScreenMap, target=)>>

2014-02-24 15:27:31.257 MyApplication [807:70b] <_MKUserInteractionGestureRecognizer: 0xc80c470; baseClass = UIGestureRecognizer; state = Began; cancelsTouchesInView = NO; delaysTouchesEnded = NO; view = ; target= <(action=handleTouch:, target=)>>

2014-02-24 15:27:31.258 MyApplication [807:70b] ; target= <(action=MySetFullScreenMap, target=)>>

2014-02-24 15:27:31.258 MyApplication [807:70b] <_MKUserInteractionGestureRecognizer: 0xc80c470; baseClass = UIGestureRecognizer; state = Began; cancelsTouchesInView = NO; delaysTouchesEnded = NO; view = ; target= <(action=handleTouch:, target=)>>

2014-02-24 15:27:31.376 MyApplication [807:70b] ; target= <(action=MySetFullScreenMap, target=)>>

2014-02-24 15:27:31.376 MyApplication [807:70b] ; target= <(action=handleLongPress:, target=)>>

2014-02-24 15:27:31.377 MyApplication [807:70b] ; target= <(action=MySetFullScreenMap, target=)>>

2014-02-24 15:27:31.377 MyApplication [807:70b] <_MKUserInteractionGestureRecognizer: 0xc80c470; baseClass = UIGestureRecognizer; state = Ended; cancelsTouchesInView = NO; delaysTouchesEnded = NO; view = ; target= <(action=handleTouch:, target=)>>

2014-02-24 15:27:31.377 MyApplication [807:70b] ; target= <(action=MySetFullScreenMap, target=)>>

2014-02-24 15:27:31.377 MyApplication [807:70b] ; target= <(action=handleTap:, target=)>; must-fail = { ; target= <(action=handleDoubleTap:, target=)>; numberOfTapsRequired = 2>, ; target= <(action=handlePan:, target=)>> }>

2014-02-24 15:27:31.378 MyApplication [807:70b] ; target= <(action=MySetFullScreenMap, target=)>>

2014-02-24 15:27:31.378 MyApplication [807:70b] ; target= <(action=handleTwoFingerTap:, target=)>; numberOfTouchesRequired = 2>

2014-02-24 15:27:31.378 MyApplication [807:70b] ; target= <(action=MySetFullScreenMap, target=)>>

2014-02-24 15:27:31.379 MyApplication [807:70b] ; target= <(action=handleTwoFingerLongPress:, target=)>>

2014-02-24 15:27:31.379 MyApplication [807:70b] ; target= <(action=MySetFullScreenMap, target=)>>

2014-02-24 15:27:31.380 MyApplication [807:70b] ; target= <(action=handlePinch:, target=)>>

2014-02-24 15:27:31.380 MyApplication [807:70b] ; target= <(action=MySetFullScreenMap, target=)>>

2014-02-24 15:27:31.380 MyApplication [807:70b] ; target= <(action=handlePan:, target=)>; must-fail-for = { ; target= <(action=handleTap:, target=)>> }>

2014-02-24 15:27:31.380 MyApplication [807:70b] ; target= <(action=MySetFullScreenMap, target=)>>

2014-02-24 15:27:31.381 MyApplication [807:70b] ; target= <(action=handleRotation:, target=)>>

2014-02-24 15:27:31.381 MyApplication [807:70b] ; target= <(action=MySetFullScreenMap, target=)>>

2014-02-24 15:27:31.381 MyApplication [807:70b] ; target= <(action=handleTilt:, target=)>>

2014-02-24 15:27:31.381 MyApplication [807:70b] ; target= <(action=MySetFullScreenMap, target=)>>

2014-02-24 15:27:31.382 MyApplication [807:70b] ; target= <(action=handleLongPress:, target=)>>

The in each case upper log is the "gestureRecognizer" and the lower one is the "otherGestureRecognizer".

I've just added a UILongPressGestureRecognizer and the UITapGestureRecognizer (for my function "MySetFullScreenMap"

user3191334
  • 1,148
  • 3
  • 15
  • 33
  • I've already posted a solution to this problem here http://stackoverflow.com/questions/17200910/mkannotationview-and-tap-detection/17203442#17203442 – HepaKKes Feb 23 '14 at 21:59
  • @HepaKKes I know this kind of solution but the point is that I have a lot of touch events. If I set a breakpoint to the "shouldRecognizeSimultaneously[...]" function and make a single tap on the mapview there are everytime more than three simultaneous events and I don't know how to decide between my tap recognizer and the one from a MKAnnotationView. – user3191334 Feb 24 '14 at 14:14
  • Let me understand a thing, are you adding a gesture recognizer to each MKAnnotationView? – HepaKKes Feb 24 '14 at 14:30
  • Oh no, sorry if it wasn't clear. I have added a tap gesture recognizer to the mapview in order to set it in fullscreen (MySetFullScreenMap). But the problem is that every time I want to click a PinAnnotation, make a double tap, etc. my function (MySetFullScreenMap) is executed instead of the system function (f.ex. opening the calloutBubble). I hope its clear now. – user3191334 Feb 24 '14 at 14:49
  • Have you found a solution for that yet? The http://stackoverflow.com/questions/17200910/mkannotationview-and-tap-detection/17203442#17203442 solution relies on knowledge of a private API that can, and have, changed over time, therefore it's not reliable. – Rodrigo Ruiz Jul 27 '14 at 22:34

1 Answers1

0

The UIGestureRecognizer class has a property for the view that it is attached to. Could that help you to determine what has been tapped?

Jakob W
  • 3,347
  • 19
  • 27
  • OK thanks! I tried it your way with the delegate function: `- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer` I get both gesture recognizer (MKUserInteractionGestureRecognizer and UITapGestureRecognizer) but unfortunately i can't find a note to separate between default from MKMapView and the tap on a annotation. Do someone know a solution for that? – user3191334 Feb 23 '14 at 21:41