当键盘出现在iOS(Cordova)时如何调整Web视图大小 [英] How to resize web view when keyboard appears on iOS (Cordova)

查看:887
本文介绍了当键盘出现在iOS(Cordova)时如何调整Web视图大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Phonegap 3.7.0上,当键盘出现在iPhone或iPad上时,Web视图不会调整大小,并且键盘位于页脚上方。我想让Web视图缩小,使页脚仍然可见。有没有反正要解决这个问题?



我已经看到很多问题,实际上实现了相反,但这是与以前的版本的Cordova / Phonegap。 p>

FYI,我尝试以下:当键盘出现时调整主体大小(我使用Ionic键盘插件知道它是什么时候显示和它的高度),并更改 bottom 我的页脚的值。这适用于iPhone 6.1.3,但不适用于iPhone / iPad 8. *。即使身体较小,身体仍然可以滚动,好像仍然是100%。我尝试使用 width = device-width 删除我的元标记内容,但它没有更改任何内容。

解决方案

一个选择是使用一个插件收缩本地WebView。将 cordova插件键盘添加到您的项目中:

  phonegap插件添加cordova-plugin-keyboard 

然后在您的config.xml中添加

 < preference name =KeyboardShrinksViewvalue =true/> 

或在您的javascript中调用此方法

  Keyboard.shrinkView(true); 


On Phonegap 3.7.0, when the keyboard appears on iPhone or iPad, the web view is not resized, and the keyboard ends up above the footer. I would like the web view to be shrunk so that the footer would remain visible. Is there anyway to fix this?

I've seen a lot of questions here to actually achieve the opposite, but that was with previous versions of Cordova/Phonegap.

FYI, I tried the following: resize the body when the keyboard appears (I use the Ionic keyboard plugin to know when it is shown and it's height) and change the bottom value of my footer. This does work on iPhone 6.1.3, but not on iPhone/iPad 8.*. Even if the body is smaller, the body is still scrollable, as if it still was 100%. I tried removing my meta tag content with width=device-width, but it didn't change anything.

解决方案

One option is to use a plugin to shrink the native WebView. Add cordova-plugin-keyboard to you project:

phonegap plugin add cordova-plugin-keyboard

then in your config.xml add

<preference name="KeyboardShrinksView" value="true" /> 

or call this method in your javascript

Keyboard.shrinkView(true);

这篇关于当键盘出现在iOS(Cordova)时如何调整Web视图大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆