lock initial orientation natively (prior to javascript execution)
Assuming I want my application to be always locked to portrait and I use Orientation.lockToPortrait(); at the javascript index. If the user opens the app while the mobile is in landscape mode - it will be the initial orientation. Thus, there's a period of time until Orientation.lockToPortrait() is called that the application is in landscape mode.
The above-mentioned behavior might cause few issues in the following scenarios:
- The javascript is being executed with the landscape mode (which affects Dimensions for example)
- Native code/screen which is displayed before react native starts, will run with the initial landscape orientation
locking the initial orientation natively can be a proper solution in that case.
Having an exact problem.
two scenarios:
-
Open an app in portrait (onboarding or stories) => then switch to landscape => everything is fine
-
confirm you’re in landscape mode by opening a different app in landscape => stay in landscape => open our app (either onboarding or main application) => it starts in the landscape, then switches to portrait but the layout is already broken
Looks like portrait orientation is applied to late?
We're having the same issue.
I'm surprised this caveat is not discussed on the README.
Same issue... would be nice to dynamically change the allowed orientation natively (e.g in android manifest).
Same, any workaround?
ios: vi react-native-orientation/iOS/RCTOrientation/Orientation.m //static UIInterfaceOrientationMask _orientation = UIInterfaceOrientationMaskAllButUpsideDown; static UIInterfaceOrientationMask _orientation = UIDeviceOrientationPortrait; //locked to portrait
android: <activity android:name=".MainActivity" android:screenOrientation="portrait" //locked to portrait