Issue
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.
Solution
Recognizing the change of zoom scale with UIGestureRecognizer
is a bad idea.
Better use the MKMapView
delegate method that is called when the region displayed by the map view is about to change.
- (void)mapView:(MKMapView *)mapView regionWillChangeAnimated:(BOOL)animated {
// detect zoom scale and update slider
}
Use the method in this answer to detect the zoom scale.
Answered By - Felix
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.