Phonegap 2.6和KeyboardShrinksView和HideKeyboardFormAccessoryBar [英] Phonegap 2.6 with KeyboardShrinksView and HideKeyboardFormAccessoryBar

查看:551
本文介绍了Phonegap 2.6和KeyboardShrinksView和HideKeyboardFormAccessoryBar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个新的phonegap功能的一个问题2.6(ios),最后他们包括一个选项收缩webview来处理固定的元素。不幸的是,将 HideKeyboardFormAccessoryBar 选项设置为true,会出现一个奇怪的白色条,而不是AccessoryView(请查看屏幕截图)。
当我将 KeyboardShrinksView 设置为false时不会发生这种情况



新版本?这是一个错误或功能? ;)



干杯
horst。

解决方案

是一个bug。它是由于在显示键盘后WebView未正确调整大小引起的。默认情况下,PhoneGap通过将视图框架减去键盘高度来调整WebView的高度。但是,它没有考虑到在该计算中隐藏表单辅助栏的事实。



这里是一个临时的解决方案,而PhoneGap修复了这个bug: / p>

在CDVViewController.m(在Classes / Cleaver下),转到第140行。它应该在(void)keyboardWilLShowOrHide函数内。在showEvent if语句中,它根据键盘的高度计算WebView的新大小。



将if语句的内容更改为:

  if(showEvent){
newFrame.size.height - = keyboardFrame.size.height;
if([@trueisEqualToString:self.settings [@HideKeyboardFormAccessoryBar]]){
newFrame.size.height + = 45;
}
}



我添加了一个额外的if语句, HideKeyboardFormAccessoryBar配置。如果设置了,它会增加WebView的大小另外45像素(表单附件栏的高度)。


i have a problem with one of the new phonegap features in 2.6 (ios), finally they included an option to shrink the webview to handle fixed elements. Unfortunately in combination with the HideKeyboardFormAccessoryBar option set to true, a strange white bar appears instead of the AccessoryView (take a look at the screenshot). This is not happening when i set KeyboardShrinksView to false

has anyone experienced a similar problem with the new version? is this a bug or a feature? ;)

cheers horst.

解决方案

This is a bug. It's caused by the WebView not being resized properly after the keyboard is displayed. By default, PhoneGap resizes the height of the WebView by subtracting the view frame by the height of the keyboard. But, it doesn't take into account the fact that the form accessory bar is hidden in that calculation.

Here's a temporary solution to this while PhoneGap fixes this bug:

In CDVViewController.m (under Classes/Cleaver), go to line 140. It should be within the (void) keyboardWilLShowOrHide function. In the showEvent if statement, it calculates the new size of the WebView based on the height of the keyboard.

Change the contents of the if statement to:

if (showEvent) {
    newFrame.size.height -= keyboardFrame.size.height;
    if ([@"true" isEqualToString: self.settings[@"HideKeyboardFormAccessoryBar"]]) {
        newFrame.size.height += 45;
    }
}

I added an extra if statement that also checks for the HideKeyboardFormAccessoryBar configuration. If it's set, it'll increase the size of the WebView by an additional 45 pixels (the height of the form accessory bar).

这篇关于Phonegap 2.6和KeyboardShrinksView和HideKeyboardFormAccessoryBar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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