【发布时间】:2019-07-25 10:19:12
【问题描述】:
我正在尝试将 HTML 内容加载到 WKWebView,它无法正确加载,与屏幕高度/宽度相同,相同的代码在 UIWebView 上工作正常,请参阅以下代码
webView.loadHTMLString(htmlString!, baseURL: nil)
HTML 字符串内容<style type="text/css"> #container { width: 667px; height: 375px; margin: 0 auto } </style> 667px 是屏幕高度,375px 是屏幕宽度。
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Highcharts Example</title>
<style type="text/css">
#container {
width: 667px;
height: 375px;
margin: 0 auto
}
</style>
</head>
<body>
<script src="https://code.highcharts.com/highcharts.js"></script>
<div id="container"></div>
<script type="text/javascript">
Highcharts.chart('container', {
//Chart code.
});
</script>
</body>
</html>
我能做些什么来解决这个问题?
【问题讨论】:
-
尝试改变 webView contentMode,它应该调整其内容的大小
-
我尝试了 contentMode 与 AspectFill、AspectFit、缩放到填充但没有得到正确的输出。
标签: ios swift uiwebview wkwebview wkwebviewconfiguration