[ 
https://issues.apache.org/jira/browse/CB-3020?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13772949#comment-13772949
 ] 

Chris Emerson edited comment on CB-3020 at 9/20/13 4:17 PM:
------------------------------------------------------------

Hey guys - I'm using (and need) the following to work: <preference 
name="KeyboardShrinksView" value="false"/>.  



I tried the above stuff and something a guy put here: 
https://github.com/cpojer/cordova-ios/commit/883ebf049bfd6a4a2b210f69b7b6bab229269eff
  but nothing got things working for me. By "working" I mean I *DON'T* want the 
keyboard to shrink my view when it appears ... which is what I need 99.5% of 
the time.

I think I have a working (hack) fix if anyone wants to try/test. All I did was 
comment out the first 3 lines of the keyboardWillShowOrHide method - after 
doing that the keyboard stopped shrinking my view - Yay! If anyone 
tests/confirms the same on their end please let me know.

*Update 1: I had some iPad issues so I updated my getting-uglier-by-the-minute 
hack a bit*

*Update 2: Looks like it works on the simulator but on the iPad itself this 
hack stops working after a few show/hide instances ... trying to resolve still*

{code:title=CDVViewController.m}

- (void)keyboardWillShowOrHide:(NSNotification*)notif
{
    // Ignore this conditional statement and just assume 
KeyboardShrinksView=true 
    // if (![@"true" isEqualToString :[self 
settingForKey:@"KeyboardShrinksView"]]) {
    //    return;
    // }

    BOOL showEvent = [notif.name 
isEqualToString:UIKeyboardWillShowNotification];

    CGRect keyboardFrame = [notif.userInfo[UIKeyboardFrameEndUserInfoKey] 
CGRectValue];
    keyboardFrame = [self.view convertRect:keyboardFrame fromView:nil];

    CGRect newFrame = self.view.bounds;
    if (showEvent) {
        // Add, don't subtract, the keyboard height to webview frame
        // newFrame.size.height -= keyboardFrame.size.height;            
        newFrame.size.height += keyboardFrame.size.height;
        // don't allow frame height to exceed 1024 (iPad)
        if(newFrame.size.height > 1024) newFrame.size.height = 1024;
        self.webView.scrollView.contentInset = UIEdgeInsetsMake(0, 0, 
-keyboardFrame.size.height, 0);
    } else {            
        self.webView.scrollView.contentInset = UIEdgeInsetsMake(0, 0, 0, 0);
    }
    // NSLog(@"running keyboardWillShowOrHide() [frame height:%f] 
[kb:%f]",newFrame.size.height, keyboardFrame.size.height);
    self.webView.frame = newFrame;
}
{code}
                
      was (Author: chrisemersonnc):
    Hey guys - I'm using (and need) the following to work: <preference 
name="KeyboardShrinksView" value="false"/>.  

I tried the above stuff and something a guy put here: 
https://github.com/cpojer/cordova-ios/commit/883ebf049bfd6a4a2b210f69b7b6bab229269eff
  but nothing got things working for me. By "working" I mean I *DON'T* want the 
keyboard to shrink my view when it appears ... which is what I need 99.5% of 
the time.

I think I have a working (hack) fix if anyone wants to try/test. All I did was 
comment out the first 3 lines of the keyboardWillShowOrHide method - after 
doing that the keyboard stopped shrinking my view - Yay! If anyone 
tests/confirms the same on their end please let me know.

Update 1: I had some iPad issues so I updated my getting-uglier-by-the-minute 
hack a bit:

{code:title=CDVViewController.m}

- (void)keyboardWillShowOrHide:(NSNotification*)notif
{
    // Ignore this conditional statement and just assume 
KeyboardShrinksView=true 
    // if (![@"true" isEqualToString :[self 
settingForKey:@"KeyboardShrinksView"]]) {
    //    return;
    // }

    BOOL showEvent = [notif.name 
isEqualToString:UIKeyboardWillShowNotification];

    CGRect keyboardFrame = [notif.userInfo[UIKeyboardFrameEndUserInfoKey] 
CGRectValue];
    keyboardFrame = [self.view convertRect:keyboardFrame fromView:nil];

    CGRect newFrame = self.view.bounds;
    if (showEvent) {
        // Add, don't subtract, the keyboard height to webview frame
        // newFrame.size.height -= keyboardFrame.size.height;            
        newFrame.size.height += keyboardFrame.size.height;
        // don't allow frame height to exceed 1024 (iPad)
        if(newFrame.size.height > 1024) newFrame.size.height = 1024;
        self.webView.scrollView.contentInset = UIEdgeInsetsMake(0, 0, 
-keyboardFrame.size.height, 0);
    } else {            
        self.webView.scrollView.contentInset = UIEdgeInsetsMake(0, 0, 0, 0);
    }
    // NSLog(@"running keyboardWillShowOrHide() [frame height:%f] 
[kb:%f]",newFrame.size.height, keyboardFrame.size.height);
    self.webView.frame = newFrame;
}
{code}
                  
> HideKeyboardFormAccessoryBar and KeyboardShrinksView show white bar instead 
> of removing it
> ------------------------------------------------------------------------------------------
>
>                 Key: CB-3020
>                 URL: https://issues.apache.org/jira/browse/CB-3020
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: iOS
>    Affects Versions: 2.6.0, 3.0.0
>         Environment: ios 6.1.3
>            Reporter: Horst Perfect
>            Assignee: Shazron Abdullah
>            Priority: Minor
>              Labels: bug, ios, ios6.1.3
>
> I use phonegap 2.6 with the two new preferences HideKeyboardFormAccessoryBar 
> KeyboardShrinksView set to true. Instead of the AccessoryBar a white bar 
> appears ([screenshot|http://i.stack.imgur.com/3fgV8.png]).
> This is just happening when i set *both* of the preferences to true. When i 
> just set the AccessoryBar preference to true the bar disappears as planned.
> Horst

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to