使用 UIWebView 呈现第三方网站。由于各种原因,我无法使用 WKWebView。
Storyboard中没有与我的 ViewController 关联的 Xib/View。所有 UI 都在 viewDidLoad() 方法中加载
let navigationBar = UINavigationBar()
navigationBar.setTranslatesAutoresizingMaskIntoConstraints(false)
navigationBar.barStyle = UIBarStyle.Black
//added navigation items
self.view.addSubview(navigationBar)
UXHelper.createHorizontalConstraints(navigationBar, outerView: self.view, margin: 0)
UXHelper.createConstraint(navigationBar, parent: self.view, to: self.view, constraint: NSLayoutAttribute.Top, margin: 0)
UXHelper.createConstraint(navigationBar, parent: self.view, to: nil, constraint: NSLayoutAttribute.Height, margin: AlgoLinkWebViewController.navBarHeight)
self.webView = UIWebView()
self.webView.backgroundColor = UIColor.whiteColor()
self.webView.opaque = false
self.webView.setTranslatesAutoresizingMaskIntoConstraints(false)
self.webView.delegate = self
self.view.addSubview(self.webView)
UXHelper.createHorizontalConstraints(self.webView, outerView: self.view, margin: 0)
UXHelper.createConstraint(self.webView, parent: self.view, to: self.view, constraint: NSLayoutAttribute.Bottom, margin: 0)
self.view.addConstraint(NSLayoutConstraint(item: self.webView, attribute: NSLayoutAttribute.Top, relatedBy: NSLayoutRelation.Equal, toItem: navigationBar, attribute: NSLayoutAttribute.Bottom, multiplier: 1, constant: 0))
下面是上面代码渲染出来的webView的截图
我正在寻找的预期 WebView 渲染是 .这是来自另一个我知道使用 UIWebView 但无权访问代码的应用程序
注意:请忽略导航栏的差异
我试过的选项是
- 删除 Autoresizing = false
- 删除它并没有删除放大状态
- webView.scalesWebPagesToFit = true
- 设置这个没有什么不同
- 使用父 View 框架大小初始化 UIWebView
- self.webView = UIWebView(frame: self.view.bounds) - 没有区别
- 将 ScrollView 比例值设置为 0.5
- 没有影响
最佳答案
也许您在 iPhone6/6plus 上使用缩放模式。
关于ios - UIWebView 以低质量的放大状态呈现网页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30471867/