Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 使用view.bounds创建WkWebView时';s框架,为什么;窗内高度“;在webview js中,是否与view.bounds.height不同?_Ios_Swift - Fatal编程技术网

Ios 使用view.bounds创建WkWebView时';s框架,为什么;窗内高度“;在webview js中,是否与view.bounds.height不同?

Ios 使用view.bounds创建WkWebView时';s框架,为什么;窗内高度“;在webview js中,是否与view.bounds.height不同?,ios,swift,Ios,Swift,在iPhone12 mini(375X812)中,我创建的wkWebView如下: let frame=CGRect(x: 0, y: 0, width: view.bounds.width, height: view.bounds.height) webView=WKWebView(frame: frame) 然后我打开一个网页,在onload中编写javascript代码“alert(window.innerHeight)”,结果是“728”,而不是“812”,为什么?在i

在iPhone12 mini(375X812)中,我创建的wkWebView如下:

    let frame=CGRect(x: 0, y: 0, width: view.bounds.width, height: view.bounds.height)
    webView=WKWebView(frame: frame)

然后我打开一个网页,在onload中编写javascript代码“alert(window.innerHeight)”,结果是“728”,而不是“812”,为什么?

在iphone 12 mini中,顶部安全区域视图为50,但底部安全区域视图为34,因此总数为812,可能是因为您得到的内部视图高度意味着没有安全区域高度,这就是为什么您得到728的结果。您可以在xcodeLook中检查安全区域,但我创建了webview,并让其高度等于view.bounds.height,所以webview的高度应该是812,对吗?