react-native-orientation icon indicating copy to clipboard operation
react-native-orientation copied to clipboard

lock initial orientation natively (prior to javascript execution)

Open orenklein opened this issue 8 years ago • 5 comments

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.

orenklein avatar Jan 11 '18 14:01 orenklein

Having an exact problem.

two scenarios:

  1. Open an app in portrait (onboarding or stories) => then switch to landscape => everything is fine

  2. 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?

codeandco-jay avatar Mar 04 '18 09:03 codeandco-jay

We're having the same issue.

I'm surprised this caveat is not discussed on the README.

dccarmo avatar Jul 03 '18 17:07 dccarmo

Same issue... would be nice to dynamically change the allowed orientation natively (e.g in android manifest).

c-goettert avatar Aug 29 '18 09:08 c-goettert

Same, any workaround?

fukuball avatar Nov 10 '19 15:11 fukuball

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

amingsc avatar May 17 '22 04:05 amingsc