Preventing iOS Keyboard from scrolling page in cordova 3.5

后端 未结 2 2202
轻奢々
轻奢々 2021-02-20 01:21

I am using Cordova 3.5 and jQuery mobile to build an iOS app. I have disabled scrolling in most of the app; however, when I select an input field, the iOS keyboard opens and scr

相关标签:
2条回答
  • 2021-02-20 02:03

    Add this plugin with

    cordova plugin add https://github.com/driftyco/ionic-plugins-keyboard.git
    

    in the command line.

    Add the following line anywhere it the javascript to disable scrolling from the keyboard.

    cordova.plugins.Keyboard.disableScroll(true);
    

    In my use case, I added a deviceready event listener to evaluate this line, disabling the automatic keyboard scrolling everywhere in the app.

    That's it!

    0 讨论(0)
  • 2021-02-20 02:06

    From my experience, and saying this as a developer who avoids 3rd party plugins as much as possible, I've found that virtual keyboard issues in Cordova are best solved with a plugin.

    The Cordova plugin directory has several keyboard plugins (http://cordova.apache.org/plugins/?q=keyboard)

    I recommend the following plugin:
    https://github.com/cjpearson/cordova-plugin-keyboard

    Which provides the following command to disable scrolling when the virtual keyboard is open.

    cordova.plugins.Keyboard.disableScrollingInShrinkView(true);
    
    0 讨论(0)
提交回复
热议问题