WKWebView的内容高度太大了

时间:2016-08-18 17:17:52

标签: javascript swift wkwebview contentsize

我已经尝试了这个类似question的所有答案来计算WKWebView的正确内容高度,但结果高度总是超出实际高度,使得在内容结尾之下的长空区域

我尝试的方式:

  1. webView.eveluateJavaScript()
  2. webView.scrollView.contentSize
  3. WKScriptMessageHandler (get the message.body.valueForKey("body"))
  4. 这是我试图加载的HTML字符串:

    > <html><head><style>img{max-width:100%%;height:auto
    > !important;width:auto !important;};</style></head><body
    > style='margin:0; padding:0; font-size:[myFontSize];
    > font-family:[myFont]; color:[myColor]'>[myHTMLstring]</body></html>
    

    有没有其他方法可以获得正确的WKWebView高度?

1 个答案:

答案 0 :(得分:-1)

  1. WKWebView,与self.view.frame设置一致性
  2. 2.试一试,

    <html>
     <head>
        <style>
           background-color:purple;
        </style>
     </head>
     <body>
     </body>
    </html>
    

    ```

相关问题