0

I'll explain: I have a UIWebView with its Scrollview. I want that the user can scroll and zoom; but when he presses a button (that I implemented) I want that my scrollview is locked: no scroll, no zoom.

To disable scroll there is this easy function:

webView.scrollView.scrollEnabled = NO;

My question is: is there a similar function to disable zoom? And if not, why in the world there isn't a similar function to disable zoom? And what can I do instead? Thank you all.

Ales
  • 19
  • 8

2 Answers2

1

Try this code for disable scroll and zoom in webview .

_webview_info.userInteractionEnabled=FALSE;

Hope this code useful for you.

Darshan Kunjadiya
  • 3,323
  • 1
  • 29
  • 31
0

None of the solutions I found worked for my exact case, so I tried removing the pinch recognizer from the gestureRecognizers array on my scroll view.

First I grabbed a reference to the pinch recognizer:

for(UIGestureRecognizer *gesture in scrollView.gestureRecognizers){
    if([gesture isKindOfClass:[UIPinchGestureRecognizer class]]){
        pinchZoomGestureRecognizer = gesture;
    }
}

Then I used the following method to add/remove the gesture from the scrollview

-(void)setScrollViewZoomEnabled:(BOOL)enabled{
    NSMutableArray *gestures = [scrollView.gestureRecognizers mutableCopy];

    if(enabled){
        [gestures addObject:pinchZoomGestureRecognizer];
    }else{
        [gestures removeObject:pinchZoomGestureRecognizer];
    }

    scrollView.gestureRecognizers = gestures;
}

This is working for me on iOS 8 - 10. Hopefully this isn't a duplicate.

John Macy
  • 11
  • 3