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
mapViewis anMKMapView, 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
delegateand implementgestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:(you can just always returnYES).You should also probably set
selfas the gesture recognizer’stargetand not themapView.