Istiak Morsalin
Istiak Morsalin

Reputation: 11159

iOS Disable Initial Zoom in webview?

I need to Disable zooming for UIWebview iOS for swift 2.2. I am trying like this:

self.webView.scrollView.maximumZoomScale = 1.0;
self.webView.scrollView.minimumZoomScale = 1.0;

But this is not helping. Is there any other way I can disable zoom while the page loads for the first time?

Upvotes: 1

Views: 713

Answers (2)

Md. Ibrahim Hassan
Md. Ibrahim Hassan

Reputation: 5467

Turn off scalesPageToFit for the webView and set the zoom level manually for the first time loading. SO Post

Hope this helps.

Upvotes: 0

Sivajee Battina
Sivajee Battina

Reputation: 4174

This works for me:

let scrollView = webView.subviews.objectAtIndex(0)
scrollView.delegate = self

func viewForZooming(in scrollView: UIScrollView) -> UIView? {
    return someView
}

UPDATE: For iOS 5 or higher get scrollView like this:

webview.scrollView.delegate = self;

You can try this also:

use 'webView.scrollView.zoomScale' instead of 1.0, and do it inside the 'webViewDidFinishLoad' (remember to set the web view delegate)

Upvotes: 1

Related Questions