ios - UIWebView 以低质量的放大状态呈现网页

标签 ios swift uiwebview

使用 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的截图

UI WebView with bigger font for Web Content

我正在寻找的预期 WebView 渲染是 .这是来自另一个我知道使用 UIWebView 但无权访问代码的应用程序

UI WebView with the expected Font size

注意:请忽略导航栏的差异

我试过的选项是

  1. 删除 Autoresizing = false
    • 删除它并没有删除放大状态
  2. webView.scalesWebPagesToFit = true
    • 设置这个没有什么不同
  3. 使用父 View 框架大小初始化 UIWebView
    • self.webView = UIWebView(frame: self.view.bounds) - 没有区别
  4. 将 ScrollView 比例值设置为 0.5
    • 没有影响

最佳答案

也许您在 iPhone6/6plus 上使用缩放模式。

关于ios - UIWebView 以低质量的放大状态呈现网页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30471867/

相关文章:

ios - UIWebView 和顶栏 iPhone 5 iPhone 4 缩放问题

ios - 获取 WKWebView 内某个区域的快照

ios - 如何同时获取indexPath.row和indexPath.section

ios - Swift 3 无法使用 UIWindow 调用函数

swift - spriteKit didBeginContact 无法添加Child

ios - 如何隐藏 Storyboard中的图像/标签以在我们运行应用程序时显示?

ios - UIWebview 重新加载不起作用

ios - 发现扩展时遇到 Swift 4 错误 - 照片无法在 UI 上加载

iphone - 在核心动画或核心图形上创建简单的橡皮擦效果有多难?

regex - Swift 2 正则表达式意外行为