简体   繁体   English

WebkitView内容高度溢出

[英]WebkitView content height overflowing

image 图片

This is the view of my webview content of which bottom is overflowing and is not visible. 这是我的Webview内容的视图,其底部溢出并且不可见。 What I figured out is the parent view of webview is covering entire screen and the child view is covering entire screen leaving app status bar area. 我发现Webview的父视图覆盖了整个屏幕,子视图覆盖了整个屏幕,留下了应用程序状态栏区域。 But both of them is having equal dimensions, and this is why my child view is overflowing downward. 但这两个尺寸相等,这就是为什么我的子视图向下溢出的原因。

I read many solution and most of them I tried but no difference is found. 我读了很多解决方案,但大多数都尝试过,但没有发现任何区别。

html file that I am loading 我正在加载的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 view 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
    }

How can I correct this UI issue 我该如何解决这个UI问题

Give the Height for Web Kit View 100 points less than the device bounds 为Web Kit View赋予高度比设备范围少100点

and then give y position to your Child view as heightOfYourWebView + 10 so the Button will be below the WebkitView and above the bottom of the screen also give width as 350 and height for button as 30 and the view will not go out of bounds 然后将您的子视图的y位置指定为heightOfYourWebView + 10,因此Button将位于WebkitView下方,并且位于屏幕底部上方,并且将width设置为350并将button的高度设置为30,并且视图不会超出范围

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

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