I have a MkMapView on which I have some Annotations. When I click an annotation Its detail is opened in another view which has scroll view in bottom half of map view. When we scroll through scrollview the map centers on next annotation and its details are shown in scrollview.
My problem is that I want to add a tap gesture on Map so that when i tap on map the scrollview should hide. For this purpose I added a UiTapGesture on map which also works fine but the issue is that annotations on map no longer remain tapable. The map always goes to action of tapgesture and it never call again the selectannotation method?
How can I fix this issue????
You can tell your gesture recognizer and the map’s to work simultaneously by implementing the
shouldRecognizeSimultaneouslyWithGestureRecognizerdelegate method.When creating the tap gesture, set its delegate:
and implement the method:
Now both your tap gesture method and the
didSelectAnnotationViewwill get called.Assuming your tap handler gets called first, you can remove and nil the scrollview there and then the didSelectAnnotationView would create and add the scrollview. If the sequence turns out to be different, you might need to add some flags to coordinate the removal/creation.