Turn off Zooming in UIScrollView Turn off Zooming in UIScrollView ios ios

Turn off Zooming in UIScrollView


If you want to disable the user's ability to zoom through gestures then in iOS 5 and above you can disable the pinch gesture. This still allows you to control the scroll view from code...

scrollView.pinchGestureRecognizer.enabled = NO;

similarly for pan...

scrollView.panGestureRecognizer.enabled = NO;

This must be called in - (void)viewDidAppear:(BOOL)animated or later as otherwise the system resets it to enabled.

Swift 4.x and above:

imageZoomView.pinchGestureRecognizer?.isEnabled = false / true


Following fbrereto's advice above, I created two functions lockZoom and unlockZoom. When locking Zoom i copied my max and min zoom scales to variables then set the max and min zoom scale to 1.0. Unlocking zoom just reverses the process.

-(void)lockZoom{    maximumZoomScale = self.scrollView.maximumZoomScale;    minimumZoomScale = self.scrollView.minimumZoomScale;    self.scrollView.maximumZoomScale = 1.0;    self.scrollView.minimumZoomScale = 1.0;}-(void)unlockZoom{    self.scrollView.maximumZoomScale = maximumZoomScale;    self.scrollView.minimumZoomScale = minimumZoomScale;}


Also you can return "nil" as zooming view in UIScrollViewDelegate:

- (UIView *) viewForZoomingInScrollView:(UIScrollView *) scrollView{    return canZoom?view:nil;}