提问人:Nazik 提问时间:6/19/2018 更新时间:6/19/2018 访问量:389
UIWebview 显示带有图像的整页
UIWebview show full page with image
问:
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)
这是有效的,但我们需要滚动 webview 才能在网页中查看完整图像。如何解决这个问题?
如何显示适合视图的完整图像?
P.S,上面网址中提到的图像在diomensions(3024x4032)中超过3000像素
答:
1赞
Vijay Kharage
6/19/2018
#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)
评论