Phonegap: completely removing the black bar from the iPhone keyboard

后端 未结 2 1977
傲寒
傲寒 2020-12-05 20:37

We\'re using Phonegap to develop our mobile app, and we borrowed code from here to remove the black next/prev/done bar from the keyboard:

https://stackoverflow.com/a

相关标签:
2条回答
  • 2020-12-05 20:55

    This worked for me: https://github.com/don/KeyboardToolbarRemover

    You will have to know though, there is no Cordova.plist file as of Phonegap 2.3.0 - instead edit your config XML file with the following:

    <plugin name="KeyboardToolbarRemover" value="KeyboardToolbarRemover" />
    

    in the branch

    0 讨论(0)
  • 2020-12-05 21:04

    replace

    [subviewWhichIsPossibleFormView removeFromSuperview];
    

    with

    UIScrollView *webScroll = [webView.subviews lastObject];
    CGRect newFrame = webScroll.frame;
    
    float accesssoryHeight = subviewWhichIsPossibleFormView.frame.size.height;
    newFrame.size.height += accesssoryHeight;
    
    [subviewWhichIsPossibleFormView removeFromSuperview];
    [webScroll setFrame:newFrame];
    

    it resize the content scroll view for the amount of missing accessory space. It is as far using "private API" as the other code. In detail it isn't using private API directly but if Apple decide to change how a view appears (in this case Keyboard and WebView) then it will crash.
    For example if they rename UIWebFormAccessory, your code will not work anymore.

    EDIT:
    on iOS 5.0+ you can call webView.scrollView directly. So you can split the code to have a pre iOS 5 fallback:

    UIScrollView *webScroll;
    if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 5.0) {
        webScroll = webView.scrollView;
    } else {
        webScroll = [webView.subviews lastObject]; // iOS 2.x (?) - 4.x
        // make sure this code runs appropriate on older SDKs
    }
    
    0 讨论(0)
提交回复
热议问题