Phonegap KeyboardShrinksView和固定在iOS上的位置未正确应用

tom*_*him 17 keyboard webview ios cordova

我使用2.9.0版本的Phonegap,我希望当键盘出现时,我的WebView会像在Android phonegap应用程序中那样缩小.我将页脚和页眉元素固定在固定位置,当键盘打开时会导致故障(页脚和页眉松开其固定位置状态).

根据phonegap文档,我认为KeyboardShrinksView设置可以解决这个问题:http://docs.phonegap.com/en/2.9.0rc1/guide_project-settings_ios_index.md.html#Project%20Settings%20for%20iOS

但经过大量的尝试,我无法使其工作,WebView不会缩小.

我想也许它可能来自我的config.xml上设置的其他偏好之间的冲突:

config.xml中

<gap:platform name="ios" />
<gap:platform name="android" />

<preference name="fullscreen" value="false" />
<preference name="webviewbounce" value="false" />
<preference name="orientation" value="portrait" />
<preference name="KeyboardShrinksView" value="true" />
Run Code Online (Sandbox Code Playgroud)

或者它可能来自元标记定义,特别是视口:

的index.html

<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height" /> 
Run Code Online (Sandbox Code Playgroud)

你知道它为什么不起作用吗?或者你有解决方法吗?

编辑:我看到它在KeyboardShrinksView = true时改变了一些东西,但是当键盘打开时,它隐藏了我的内容的底部(包括我的页脚和字段),而不是调整整个内容的大小.我希望它将我的页脚放在键盘顶部,对不对?

谢谢您的帮助

Chr*_*son 4

是的——现在处理这个问题很痛苦。目前还没有真正的修复方法可以让事情像以前在 iOS 中那样。就我个人而言,我目前在我的应用程序中使用两种不同的标签(一种用于 iOS,一种用于 Android),它接近 iOS 上的旧行为。这是我使用的:

<!-- IOS --> <meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0, maximum-scale=1.0, target-densityDpi=device-dpi" />`
<!-- ANDROID --> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=1" />
Run Code Online (Sandbox Code Playgroud)

我的 config.xml 设置是您所期望的:

<preference name="HideKeyboardFormAccessoryBar" value="true" />
<preference name="KeyboardShrinksView" value="false" />
Run Code Online (Sandbox Code Playgroud)

这里有一些链接需要密切关注不断地bug(即请求)Cordova 人员最终修复它。

希望这些链接至少可以帮助您了解有关键盘缩小相关问题的最新信息。如果其他人有这方面的线索/链接,请分享!