I have a single view on my iOS application, with a mapView in it.
When adding a tap or long press recognizer, the events are properly called.
But not with the pinch event...
UIPinchGestureRecognizer *handlePinchGesture=[[UIPinchGestureRecognizer alloc]initWithTarget:mapView action:@selector(handleGesture:)];
[mapView addGestureRecognizer:handlePinchGesture];
Any idea what I should add ? Thanks.
Assuming your mapView
is an MKMapView
, it has its own pinch gesture recognizer for zooming the map.
If you want to add your own recognizer, you have to allow it to recognize simultaneously with the other (mapview-controlled) recognizer. Set your gesture recognizer's delegate
and implement gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:
(you can just always return YES
).
You should also probably set self
as the gesture recognizer's target
and not the mapView
.