image
这是我的 Web 视图内容的视图,其底部溢出且不可见。我发现的是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>
网络套件视图
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
}
如何更正此 UI 问题
为 Web 套件视图指定高度 比设备边界小 100 磅
然后将 y 位置分配给您的子视图作为高度您的 WebView + 10,因此按钮将位于 WebkitView 下方和屏幕底部上方,宽度为 350,按钮高度为 30,视图不会超出界限