繁体   English   中英

WebkitView内容高度溢出

[英]WebkitView content height overflowing

图片

这是我的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
    }

我该如何解决这个UI问题

为Web Kit View赋予高度比设备范围少100点

然后将您的子视图的y位置指定为heightOfYourWebView + 10,因此Button将位于WebkitView下方,并且位于屏幕底部上方,并且将width设置为350并将button的高度设置为30,并且视图不会超出范围

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM