Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to reset zoom for UIWebView in IOS

I have an UIWebView with scalesPageToFit = YES and contentMode = UIViewContentModeScaleToFill and it zooms automatically to fit my UIWebView size after page loads.

I can zoom in with pinch gesture but then I cannot reset the zoom by code to it's initial state (just after webViewDidFinishLoad).

The only solution I found was to reload the uiwebview but i don't want it.

Any suggestions?

EDIT

I can make it work like this

  [self.webView.scrollView zoomToRect:CGRectMake(0, 0, self.webView.scrollView.contentSize.width, self.webView.scrollView.contentSize.height) animated:YES];
    CGPoint top = CGPointMake(0, 0);
    [self.webView.scrollView setContentOffset:top animated:YES];

but I need to know how long does these animations take...with animated:NO it does not work


1 Answers

Try this to zoom in/out webview

 webView.scrollView.zoomScale = 1;
like image 69
Rajesh Choudhary Avatar answered Dec 03 '25 16:12

Rajesh Choudhary



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!