【发布时间】:2019-02-04 19:22:21
【问题描述】:
这是我的 webview 内容的视图,其底部溢出并且不可见。我发现webview的父视图覆盖了整个屏幕,子视图覆盖了整个屏幕,离开了应用程序状态栏区域。但是它们的尺寸相同,这就是为什么我的子视图向下溢出的原因。
我阅读了许多解决方案,其中大部分我都尝试过,但没有发现任何区别。
我正在加载的html文件
<!doctype html>
<html lang="en">
<head>
<meta name="viewport" content="user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, heigth=device-height, width=device-width">
<meta name="format-detection" content="telephone=no">
<meta name="msapplication-tap-highlight" content="no">
<meta charset="utf-8">
<title>XYZ</title>
<base href=".">
<!-- <meta name="viewport" content="width=device-width, initial-scale=1"> -->
<link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body>
<root id="app-root"></root>
<script type="text/javascript" src="runtime.js"></script><script type="text/javascript" src="polyfills.js"></script><script type="text/javascript" src="styles.js"></script><script type="text/javascript" src="vendor.js"></script><script type="text/javascript" src="main.js"></script></body>
</html>
webkit 视图
static func getWebKitView(uiController : ViewController, handlerName : String) -> WKWebView {
let controller = WKUserContentController()
controller.add(uiController as! WKScriptMessageHandler, name: handlerName)
let config = WKWebViewConfiguration()
config.userContentController = controller
let webKitView = WKWebView(frame: .init(x: 0.0, y: 0.0, width: DeviceInfo().getDeviceBounds().w, height: DeviceInfo().getDeviceBounds().h-2), configuration: config)
webKitView.backgroundColor = UIColor.yellow
webKitView.scrollView.isScrollEnabled = false
// webKitView.frame.size = webKitView.scrollView.contentSize
webKitView.scrollView.contentSize = webKitView.frame.size
webKitView.allowsBackForwardNavigationGestures = true
return webKitView
}
如何纠正这个用户界面问题
【问题讨论】:
-
为您的 WebkitView 设置约束,并在其下方放置其他所需的选择元素,它应该可以正常工作
-
网页视图在屏幕内。是 webview 的内容没有正确显示
-
你说的是稍后再试按钮
-
是的那个按钮出现在由 webview 显示的 ui 中
标签: javascript ios css swift wkwebview