简体   繁体   中英

iOS Swift: UIWebView has extremely big content

I have a UIWebView that is loading local html, css and javascript.

The problem is that all the assets of the html projects are displayed very very big.

I've tried to play around with webView scale factor and nothing changes..

I've even tried this inside the didFinishLoad :

let contentSize:CGSize = webView.scrollView.contentSize
        let viewSize:CGSize = self.view.bounds.size

        let rw: CGFloat = viewSize.width / contentSize.width

        webView.scrollView.minimumZoomScale = rw
        webView.scrollView.maximumZoomScale = rw
        webView.scrollView.zoomScale = rw

But still, all the images are too bigggg.

Any help?

try this code on viewdidload

self.webView.scalesPageToFit = YES
self.webView.contentMode = UIViewContentModeScaleAspectFit

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM