[ 
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 6:57 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 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-

-Update 3: Ok - after some more testing/code-mangling I think I got this hack 
working consistently now - on both IOS devices AND the simulator. I can't claim 
to know how/why really as this issue is so quirky - but at least my view isn't 
being shrunk by the keyboard for now!-

Update 4: This is getting ridiculous I know. This hack fix now includes way to 
add a css class to <body> on keyboard show/hide. This is something I may/may 
not keep using going forward - though I suppose thing belongs in a plugin not 
the CDVViewController.m file ... but alas it remains in this keyboardshrinkview 
fix for now. I've also moved my scary hack code to a Gist here to spare this 
thread any unnecessary pain and suffering

h4. https://gist.github.com/cemerson/6642026

I will stay tuned for a cleaner/actual fix for this issue ...



                
      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* -first version removed-

*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* 
-second version removed-

*Update 3: Ok - after some more testing/code-mangling I think I got this hack 
working consistently now - on both IOS devices AND the simulator*. I can't 
claim to know how/why really as this issue is so quirky - but at least my view 
isn't being shrunk by the keyboard for now! Dear God please someone fix w/a 
clean/logical fix when you can!

{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, 0, 0); 
//-keyboardFrame.size.height, 0);
    } else {
        self.webView.scrollView.contentInset = UIEdgeInsetsMake(0, 0, 0, 0);
    }

    // NSLog(@"keyboardWillShowOrHide() [webView height:%f | keyboardFrame 
height:%f]",newFrame.size.height, keyboardFrame.size.height);

    // this seems to be needed every pass otherwise the device (iPad)
    // starts shrinking the webview again
    self.webView.scrollView.contentInset = UIEdgeInsetsMake(0, 0, 0, 0);

    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