Horst
Horst

Reputation: 417

Phonegap 2.6 with KeyboardShrinksView and HideKeyboardFormAccessoryBar

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.

Upvotes: 3

Views: 2413

Answers (4)

TWilly
TWilly

Reputation: 4943

While the keyboard is transitioning up, it seems the webview is already resized and the background is white, thus causing the white background to be shown. My HTML body background is black so it looks odd when the white background flashes. Does anyone know how to update the background of the UIView?

Video reproducing the issue in slow motion. http://www.youtube.com/watch?v=iOjdxJuYp8c

Thanks!

Tom

Edit: I was able to change the background color by adding this code to MainViewConetroller.m

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.view.backgroundColor = [UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1];
}

Upvotes: 1

Ariel Erlijman
Ariel Erlijman

Reputation: 372

I have just checked my code and I have 2.6 and this fix is already there. But it is not working and I still see the grey bar with the same conditions. How that could be?

EDIT: It looks like that one of my teammates did this fix and solved the issue. The thing is that you still can see the grey space and it is removed very quickly.

Upvotes: 0

David Zhang
David Zhang

Reputation: 96

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).

Upvotes: 5

Horst
Horst

Reputation: 417

It's definitely a bug. The phonegap dev team is going to fix this issue in the 2.7 release in a few weeks.

Upvotes: 0

Related Questions