键盘显示后iOS的分割屏幕宽度

eb1

我刚刚开始研究我的Cordova应用程序中对分屏多任务的支持。到目前为止,该应用程序可以在模拟器中的iPad上显示并调整大小,但是当我单击编辑字段并显示软键盘时,宽度为100%的值将开始返回整个屏幕,而不是返回给定的窗口。

初始显示(右侧的应用程序)

初步展示-到目前为止,效果很好...

键盘显示,宽度错误

不。该应用程序现在显示在其窗口之外。

页面HTML:

<html>
  ...
  <body>
    <div class="page">
    ...
    </div>
  </body>
</html>

CSS:

.page {
  height: 100%;
  left: 0;
  position: absolute;
  top: 0;
  width: 100%;
}

编辑:视口元

<meta name="viewport" content="initial-scale=1, user-scalable=no, minimum-scale=1, maximum-scale=1, viewport-fit=cover">

Before the keyboard displays, I have a computed width of 551px for the page class div. After the keyboard displays, I have a computed width of 1112px. Any idea why displaying the keyboard would cause the width to return an incorrect value -- or what I can do to get a correct app width? I should also mention that I'm using the cordova-plugin-keyboard for some keyboard functions.

Connor

It looks like this issue is coming from the Keyboard Plugin. The shrinkView logic works by directly resizing the frame of the WebView which affects the page width. In this case, it's calculating the intersection of the keyboard and the whole screen instead of just your application's window.

我能够重现类似的行为,并插入了一个似乎可以解决该问题的补丁(感谢Jin Lei)我想在发布版本之前进行更多测试,但是您可以直接从GitHub安装更新的插件,或在本地手动应用补丁。

cordova plugin add https://github.com/cjpearson/cordova-plugin-keyboard

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章