user1620350
user1620350

Reputation:

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

Upvotes: 3

Views: 985

Answers (1)

Rajesh Choudhary
Rajesh Choudhary

Reputation: 1340

Try this to zoom in/out webview

 webView.scrollView.zoomScale = 1;

Upvotes: 1

Related Questions