views:

844

answers:

2

Does anyone know a way to temporarily turn off zooming when using a UIScrollView?

I see that you can disable scrolling using the following:

self.scrollView.scrollEnabled = false;

but I'm not seeing a similar command for zooming. Any thoughts?

+6  A: 

Check setting minimumZoomScale and maximumZoomScale; According to the docs:

maximumZoomScale must be greater than minimumZoomScale for zooming to be enabled.

So, setting the values to be the same should disable zooming.

fbrereto
+5  A: 

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;

}
CodingWithoutComments