apache / cordova-ios

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

builds with cordova-ios@6.0.0 are locked in portrait view #899

Closed eradin closed 4 years ago

eradin commented 4 years ago

Bug Report

Problem

Build with V6.0.0, splash screen and app will always be in portrait view even when device is in landscape orientation.

What is expected to happen?

Iphone and ipad should reorient app based on orientation.

Environment, Platform, Device

Confirmed on ipad 6th gen, IOS 13

Version information

<plugin name="cordova-plugin-camera" spec="4.1.0" />
<plugin name="cordova-plugin-file" spec="6.0.2" />
<plugin name="cordova-plugin-media" spec="5.0.2" />
<plugin name="cordova-plugin-file-opener2" spec="3.0.0" />
<plugin name="cordova-plugin-inappbrowser" spec="4.0.0" />
<plugin name="cordova-plugin-splashscreen" spec="5.0.4" />
<plugin name="cordova-plugin-keyboard" spec="1.2.0" />
<plugin name="cordova-plugin-statusbar" spec="2.4.3" />
<plugin name="cordova-plugin-whitelist" spec="1.3.4" />
<plugin name="phonegap-plugin-push" spec="2.3.0" />
<plugin name="cordova-plugin-device" spec="2.0.3" />

cordova 9 cli cordova-ios 6.0.0

Checklist

timbru31 commented 4 years ago

We merged some fixes for splashscrens, can you test the current master and see if the problem is already fixed? You can do so by adding the platform via cordova platform add https://github.com/apache/cordova-ios.git

antikalk commented 4 years ago

@timbru31 I am currently using the master branch of cordova-ios and experiencing the same issue. (only tested in the ios simulator though)

kamhawy4 commented 4 years ago

same problem when i'm use v 6.0.0 and 6.1.0-dev

eradin commented 4 years ago

@antikalk, @kamhawy4, On 6.0.0, my splash screen isn't respecting the 3 second default. It appears for about .5 seconds. Are you still seeing that on the mast branch?

antikalk commented 4 years ago

@eradin There has been a PR merged into the master branch, that fixed the fast disappearing splash screen error. For me using the master branch solved my splash screen problems. Keep in mind using the master branch is not recommended for production.

mosabab commented 4 years ago

For iOS you should use the preference for orientation and set value to all like this <preference name="Orientation" value="all" />

This will set when cordova add the platform and tell the platform for iOS to make all possible orientation for iOS devices.

Please note: In the past, if you don't use the preference orientation with value all or even if you omit this preference, the orientation was set for both landscape and portrait mode (like Android), but recently you should use the preference orientation with value all to see both orientation modes.

antikalk commented 4 years ago

@mosabab Thank you very much, that works for me 👍

eradin commented 4 years ago

@mosabab Shouldn't this be the default? It has been on prior versions.

breautek commented 4 years ago

The default is the Xcode default, I believe.

Default: default Allowed values: default, landscape, portrait Allows you to lock orientation and prevent the interface from rotating in response to changes in orientation. NOTE: The default value means Cordova will strip the orientation preference entry from the platform's manifest/configuration file allowing the platform to fallback to its default behavior. For iOS, to specify both portrait & landscape mode you would use the platform specific value 'all'.

https://cordova.apache.org/docs/en/latest/config_ref/index.html

eradin commented 4 years ago

@breautek That's fine but what if you don't include this directive? From everything I can find online, the ios default has always been "all" (same with android). So are you saying that the default WKWEBVIEW orientation is portrait? If that's the case, then to get "traditional legacy behavior", this directive would be mandatory. This seems odd to me as the behavior is in contrary to all previous views (i.e. UIWEBVIEW) and ios versions.

breautek commented 4 years ago

but what if you don't include this directive?

Then it defaults to default, which is the underlying tool's default setting. Cordova doesn't impose an opinion here.

So are you saying that the default WKWEBVIEW orientation is portrait?

All I'm saying is that Cordova's default is to let Xcode (or Android SDK for android) decide what the default should be and not all, even if default behaviour was all, previously. This means the default behaviour could end up changing if the underlying tools decided to change their defaults.

I don't know if this is the exact reason for the change of behaviour between cordova-ios@5 and cordova-ios@6, or between UIWebView & WKWebView. If I were to make a guess, I would think it's the difference between Xcode versions... but this is something that I think should be investigated to confirm it is indeed a regression.

eradin commented 4 years ago

Thanks for the clarification. "but this is something that I think should be investigated to confirm it is indeed a regression". Indeed.

dpogue commented 4 years ago

I believe https://github.com/apache/cordova-ios/pull/615 is what caused this.

I also believe that using the platform defaults by default is the behaviour that we want, and people should use the Orientation preference to specify behaviour for their apps.

mosabab commented 4 years ago

@eradin Anyway, if you need your project to be as you need, just set the preference orientation value to all or what you need, to keep your project as you want even if the default could be change in the future.

mosabab commented 4 years ago

Additional information:

I have another issue like what you mentioned here.

I was put the the preference for statusbarstyle to lightcontent or just i omit this preference (because the default value in doc is lightconent https://github.com/apache/cordova-plugin-statusbar#configxml) , and i see that Xcode always read the statusbar style to dark content (dark text, for light background).

So, I change the statusbar style manually to make light content instead of dark, because this preference <preference name="StatusBarStyle" value="lightcontent" /> is broken and not read by iOS any more.

So to fix this issue i do it manually by JS code like this:

function onDeviceReady() {

StatusBar.styleLightContent(); }

For that reason i open a new issue https://github.com/apache/cordova-plugin-statusbar/issues/192 regarding this problem.

dpogue commented 4 years ago

I also believe that using the platform defaults by default is the behaviour that we want

Just double checked what a newly-created iOS project has as defaults in Xcode, and it does specify certain default rotations:

    <key>UISupportedInterfaceOrientations</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationLandscapeRight</string>
    </array>
    <key>UISupportedInterfaceOrientations~ipad</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
        <string>UIInterfaceOrientationPortraitUpsideDown</string>
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationLandscapeRight</string>
    </array>
dpogue commented 4 years ago

This will be fixed when 6.1.0 is released.