How to prevent keyboard push up webview at iOS app using phonegap(如何使用 phonegap 在 iOS 应用程序中防止键盘上推 webview)
问题描述
当屏幕底部的输入字段获得焦点时,键盘将我的 webview 向上推,页面的上部不再可见.
When an input field at bottom of the screen has focus, the keyboard pushes up my webview and the upper part of the page is not visible anymore.
我想防止键盘向上推 webview.
I want to prevent the keyboard pushing up the webview.
有人有想法吗?
推荐答案
在焦点上,设置 window.scrollTo(0,0); 这样可以防止键盘完全上推 webview
On focus, set window.scrollTo(0,0); This prevents keyboard from pushing up webview completely
$('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 滚动位置设置静态值,请随意使用此 我编写的短插件可以自动在输入字段下方对齐键盘.它并不完美,但它可以完成工作.只需将其称为焦点,如上所示:
If you don't want to set a static value for your Y scroll position, feel free to use this short plugin I've written that automatically aligns the keyboard underneath the input field. It's not perfect, but it does the job. Just call this on focus as shown above:
setKeyboardPos(e.target.id);
这篇关于如何使用 phonegap 在 iOS 应用程序中防止键盘上推 webview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何使用 phonegap 在 iOS 应用程序中防止键盘上推


- Android - 拆分 Drawable 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01
- android 4中的android RadioButton问题 2022-01-01
- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01