【问题标题】:Disabling pinch zoom in Flutter team's webview在 Flutter 团队的 webview 中禁用捏合缩放
【发布时间】:2020-05-09 09:57:18
【问题描述】:

你好,flutter 团队的 webview 插件有在 iOS 中禁用缩放缩放的功能吗?在社区插件中,它的withZoom 但我不知道如何在 Flutter 团队的 webview 中做到这一点。或者团队的插件中是否有等效的功能?

我有理由要使用官方的 webview 插件。

请帮助。谢谢。

【问题讨论】:

    标签: flutter webview flutter-test


    【解决方案1】:

    我注入 javascript 代码以将元标记替换为 name = "viewport" 以禁用最大缩放。

    controller.evaluateJavascript("var meta = document.getElementsByTagName('meta');"
        "for (var i = 0; i < meta.length; i++) {"
          "if (meta[I].attribute('name') == null) continue;"
          "if (meta[i].attribute('name').includes('viewport')) {"
            "document.getElementsByTagName('meta')[i].remove();"
            "break;"
            "}"
        "}"
        "document.getElementsByTagName('head')[0].innerHTML += "
        "\"<meta name='viewport' content='initial-scale=1.0, maximum-scale=1.0'>\";"
    );
    

    当然,您需要在 WebView 中启用 Javascript。

    【讨论】:

      猜你喜欢
      • 2011-06-28
      • 2020-03-30
      • 1970-01-01
      • 2017-10-28
      • 2012-01-04
      • 1970-01-01
      • 1970-01-01
      • 2012-05-07
      • 1970-01-01
      相关资源
      最近更新 更多