如何使用phonegap防止键盘在iOS应用程序中推送webview

当屏幕底部的输入字段具有焦点时,键盘会向上推动我的webview,并且页面的上半部分不再可见.

我想阻止键盘推高webview.

有人有想法吗?

解决方法

在焦点上,设置window.scrollTo(0,0);这可以防止键盘完全推送webview

$('input').on('focus',function(e) {
    e.preventDefault(); e.stopPropagation();
    window.scrollTo(0,0); //the second 0 marks the Y scroll pos. Setting this to i.e. 100 will push the screen up by 100px. 
});

如果您不想为Y滚动位置设置静态值,请随意使用此short plugin I’ve written that automatically aligns the keyboard underneath the input field.它并不完美,但它可以完成工作.只需在焦点上调用它,如上所示:

setKeyboardPos(e.target.id);

相关文章

当我们远离最新的 iOS 16 更新版本时,我们听到了困扰 Apple...
欧版/美版 特别说一下,美版选错了 可能会永久丧失4G,不过只...
一般在接外包的时候, 通常第三方需要安装你的app进行测...
前言为了让更多的人永远记住12月13日,各大厂都在这一天将应...