I have this code:
[scrollView setMinimumZoomScale:1.00];
[scrollView setMaximumZoomScale:2.00];
scrollView.delegate=self;
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
NSSet *allTouches = [event allTouches];
if ([allTouches count] == 2) {
NSLog(@"multitouch");
zoomMultiTouch = TRUE;
}
else if ([allTouches count] == 1){
NSLog(@"single touch");
zoomMultiTouch = FALSE;
}
else return;
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
if (zoomMultiTouch){
scrollView.userInteractionEnabled = YES;
scrollView.scrollEnabled = YES;
NSLog(@"zoomMultitouch moved");
}
else {
scrollView.userInteractionEnabled = NO;
scrollView.scrollEnabled = NO;
NSLog(@"NOzoom moved");
}
//some code for coloring an image
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
scrollView.userInteractionEnabled = NO;
scrollView.scrollEnabled = NO;
zoomMultiTouch = FALSE;
}
as you can see, I want to zoom scrollView with an image inside; when I touch scrollView with a finger I color image, instead when I touch with two fingers scrollview, I want to do a zoom on it, and after if I touch with a finger zomm must be disabled.
with my code it don’t happen; it recognize double touch but don’t active zoom, why?
I think the problem is that you are not implementing all required delegate methods for zooming.
Hope it helps.
UIScrollView Class Reference