apache / cordova-ios

Apache Cordova iOS
https://cordova.apache.org/
Apache License 2.0
2.16k stars 987 forks source link

white space after update cordova 6.0.0 #905

Closed kamhawy4 closed 4 years ago

kamhawy4 commented 4 years ago

appeared me white space after update cordova 6.0.0

Image from iOS

\\\\

and after close keyboard. appearing in large more

\\\\

Image from iOS-2

dpogue commented 4 years ago

See https://github.com/apache/cordova-ios/issues/417.

This was a bug in iOS between iOS 12.0 and iOS 13.4 when using WKWebView. https://www.npmjs.com/package/cordova-plugin-wkkeyboardfix is available as a unofficial/unsupported workaround.

lovelyelfpop commented 4 years ago

Add some code in CordovaLib/Classes/Private/Plugins/CDVWebViewEngine/CDVWebViewEngine.m

    // re-create WKWebView, since we need to update configuration
    WKWebView* wkWebView = [[WKWebView alloc] initWithFrame:self.engineWebView.frame configuration:configuration];
    // add begin
    #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000
    if (@available(iOS 11.0, *)) {
        [wkWebView.scrollView setContentInsetAdjustmentBehavior:UIScrollViewContentInsetAdjustmentNever];
    }
    #endif
    // add end
    wkWebView.UIDelegate = self.uiDelegate;
dpogue commented 4 years ago

@lovelyelfpop We have said many times, we will not set UIScrollViewContentInsetAdjustmentNever because it removes control from the app author. Every app should define their content inset behaviour with the viewport-fit meta tag.

lovelyelfpop commented 4 years ago

We've already set viewport-fit=cover, but there is still white space at the first launch, after resume from background, the white space disappears. Or turn to landscape and back, the white space disappears, too.

If use viewport-fit=cover and body {height:100%}, the height of html body still can not reach the bottom, but the background-color of body can cover the fullscreen(so it's a body backgroundColor space rather than a white space).

Change height: 100% to height: 100vh fix the problem, but is has other side effects.

Maybe add a new <preference> to control it?

21pg commented 3 years ago

Agree with @lovelyelfpop , I can confirm viewport-fit=cover not resolving this problem. At first launch there is a white space below to notch on iPhone X and iPhone XR and it goes when we switch App in background/foreground I also tried height: 100vh in body/html tag. It giving me result like this- IMG1

While i expected this- IMG2

lovelyelfpop commented 3 years ago

Add a new preference would shut us up

lovelyelfpop commented 3 years ago

I write a plugin for cordova-ios@6+ to solve this issue https://github.com/lovelyelfpop/cordova-plugin-wkwebview-inset-adjustment-never