I have a mapView, in my mapView you can zoom with double tap, pinch, UIButton (+ and -) and with an UISlider.
Now… I want recognize the doubletap and the pinch, to refresh the position of UISlider… I use a NSInteger variable called zoomLevel to make this.
I have tried two way, but not working:
1)
UIGestureRecognizer *recognizer;
// taps
recognizer = [[ UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap)];
tapGR = (UITapGestureRecognizer *)recognizer;
tapGR.numberOfTapsRequired = 2;
tapGR.cancelsTouchesInView = NO;
[self.view addGestureRecognizer:tapGR];
[recognizer release];
2)
- (void)touchesEnded:(NSSet *)touches withEvent: (UIEvent *) event{
UITouch* touch = [[event allTouches] anyObject];
NSLog(@"2 taps");
if(touch.tapCount == 2 ){
NSLog(@"2 taps");
[self zoomLevelWithMapView:mappa];
}
Can someone help me?
Better with pratical example
Thank you.
Recognizing the change of zoom scale with
UIGestureRecognizeris a bad idea.Better use the
MKMapViewdelegate method that is called when the region displayed by the map view is about to change.Use the method in this answer to detect the zoom scale.