Disabling the zoom function in UIWebView

I am new to iOS development and I am developing an application to be displayed and a webpage in UIWebView . I want to get rid of the default zoom-in and zoom-out functionality of << 23>.

+6
source share
11 answers

This is in the Apple documentation:

 @property(nonatomic) BOOL scalesPageToFit Discussion If YES, the webpage is scaled to fit and the user can zoom in and zoom out. If NO, user zooming is disabled. The default value is NO. 

Interface Approach:

  • Make sure that the โ€œScale Pages In Fit" checkbox in the column to the right of the interface designer does not have a checkmark when you click on your webview. This is right upstairs.

  • You will also need to uncheck the box for โ€œMultiple Tapsโ€ about halfway down. This will disable compression to increase.

Code Approach:

You can also do this programmatically using this code:

 webView.scalesPageToFit = NO; 

You will also want to add:

 webView.multipleTouchEnabled = NO; 

This will disable the ability to pinch and scale, since it disables the ability to use multiple fingers in action, and two are required to clamp, obviously!

+25
source

set the UIWebView scalesPageToFit property to NO, will disable user scaling

 myWebView.scalesPageToFit = NO; 
+6
source

Just need to do:

myWebView.scalesPageToFit = NO;

and also turn off the annoying clip to enlarge:

webView.multipleTouchEnabled = NO;

+5
source
 UIScrollView *scrollView = [webView.subviews objectAtIndex:0]; scrollView.delegate = self;//self must be UIScrollViewDelegate - (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView { return nil; } 

try this ... It works ..

+2
source

When inheriting from UIWebView you can implement. (Works from iOS 5, not sure below)

 - (UIView *) viewForZoomingInScrollView:(UIScrollView *) scrollView { return nil; } 
+1
source

Try the following:

 - (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView { return nil; } 
+1
source

Fast decision

Just set the above value to false: webView.scalesPageToFit = false

+1
source

Disable bouncesZoom scrollView to solve your problem. Give it a try!

 webView.scrollView.bouncesZoom = false 
+1
source

To add to the answers, this will work:

 webView.scrollView.multipleTouchEnabled = NO; 
0
source

I also start the fight first when I use the webview scroll event after I love the code below to disable scrolling in the webview, and it also removes the multitouch gesture function in that particular webview.

[[[theWebView subviews] lastObject] setScrollEnabled: NO];

here theWebView is the name of my UIWebView .. use this code in the webViewDidFinishLoad function, its really useful for me, ..

0
source

For me, the ideal solution was, surprisingly, only on the html side. Just add this to the <head> :

 <meta name="viewport" content="user-scalable=0" /> 

I do not recommend using webView.scalesPageToFit = false because it brings issues such as an increase of only 4 times. I also did not use initial-scale=1.0 , maximum-scale=1.0 and minmum-scale=1.0

0
source

Source: https://habr.com/ru/post/1400503/


All Articles