Nazik
Nazik

Reputation: 8444

UIWebview show full page with image

let url = NSURL (string: "https://i.sstatic.net/0LSmY.jpg");
 let webViewInst: UIWebView = UIWebView()
 let requestObj = NSURLRequest(url: url! as URL)
 webViewInst.frame = self.view.bounds
 webViewInst.loadRequest(requestObj as URLRequest);
 webViewInst.delegate = self

 webViewInst.scalesPageToFit = true
 webViewInst.contentMode = .scaleAspectFit
 self.view.addsubview(webViewInst)

This is working, but we need to scroll the webview to see full image in the web page. How to fix this?

How to show the full image fit to the view?

P.S, the image that mentioned in the above url is more than 3000 pixel in diomensions(3024x4032)

Upvotes: 0

Views: 391

Answers (1)

Vijay Kharage
Vijay Kharage

Reputation: 411

Try this one I have implemented it and working as you expected.

webView = WKWebView(frame: self.view.frame)
let urlString = "https://i.sstatic.net/0LSmY.jpg" 
let url = URL(string: urlString)!
let request = URLRequest(url: url)
webView.load(request)
self.view.addSubview(webView)
self.view.sendSubview(toBack: webView)

Upvotes: 1

Related Questions