Why does my Cordova WebView have an extra 20px of scrolling?

淺唱寂寞╮ 提交于 2019-12-03 04:59:50
Matt Huggins

Figured it out after almost 8 hours of tinkering. Had to replace the meta viewport setting from this:

<meta name="viewport" content="user-scalable=no, initial-scale=1,
        maximum-scale=1, minimum-scale=1, width=device-width,
        height=device-height, target-densitydpi=device-dpi" />

to this:

<meta name="viewport" content="user-scalable=no, initial-scale=1,
        maximum-scale=1, minimum-scale=1, target-densitydpi=device-dpi" />

It seems that height=device-height was taking the full device height into account, including the status bar. I did see a way to work around this in JavaScript for those who are interested, which is covered by this StackOverflow answer. I don't see any drawback to removing altogether though (for a Cordova app targeting iOS 6+).

Did you try this on deviceready?

window.StatusBar.overlaysWebView(false);

https://github.com/apache/cordova-plugin-statusbar/blob/master/doc/index.md

Ionic + AngularJs

.run(['$rootScope', '$state', function ($rootScope, $state) {
            //set status bar 
            $cordovaStatusbar.styleHex('#637386');
            $cordovaStatusbar.overlaysWebView(true);

            $rootScope.$on('$stateChangeStart',
                function(event, toState, toParams, fromState, fromParams) {
                    //for me was helpful this call
                    $cordovaStatusbar.overlaysWebView(true);

                });
}])
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!