WKWebView水平滚动

时间:2018-11-28 15:12:04

标签: ios swift wkwebview

我正在使用WKWebView,而我要显示的页面水平确实很大,WKWebView试图将所有内容放入视图中,并且看起来确实缩小了。有没有一种方法可以使WKWebView可滚动而不缩小?它可以垂直滚动,但不能水平滚动。

//Create a new Web View
webView = WKWebView()

//Assign the Web View Delegate to self
webView.navigationDelegate = self

//Define and populate the URL for the Web View
let url = URL (string: "http://www.example.com");

//Load the URL into the Web View
webView.load(URLRequest(url: url!))

//Assign the Web View as the View
view = webView

这是结果

enter image description here

有什么办法解决这个问题?

1 个答案:

答案 0 :(得分:0)

我能够通过将以下内容添加到我的HTML中来解决此问题:

<meta name="viewport" content="initial-scale=1.0" />
相关问题