let url = NSURL (string: "https://i.stack.imgur.com/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)
这是可行的,但是我们需要滚动Web视图以查看网页中的完整图像。该如何解决?
如何显示适合视图的完整图像?
P.S,以上网址中提到的图像尺寸超过3000像素(3024x4032)
答案 0 :(得分:1)
尝试这个我已经实现了,并且可以按预期工作。
webView = WKWebView(frame: self.view.frame)
let urlString = "https://i.stack.imgur.com/0LSmY.jpg"
let url = URL(string: urlString)!
let request = URLRequest(url: url)
webView.load(request)
self.view.addSubview(webView)
self.view.sendSubview(toBack: webView)