React-native-orientation: Locking doesn't rotate the interface when device is already rotated properly

Created on 10 Jul 2017  路  4Comments  路  Source: yamill/react-native-orientation

I have two components. One of them (B) locks to portrait and the other one (A) -- to landscape right.

To reproduce:

  1. Load A
  2. Rotate the device to portrait
  3. Click a button to make it switch to component B

Expected

  • Interface is autorotated to portrait
  • AppDelegate's application supportedInterfaceOrientationsForWindow was called

Actual

  • Interface stays in landscape
  • AppDelegate's application supportedInterfaceOrientationsForWindow is not called

Workaround

If I want to lock the orientation and also make sure that interface is autorotated, I lock orientation to opposite value first:

Orientation.lockToPortrait()
Orientation.lockToLandscapeRight()

Most helpful comment

Alternative workaround (which is better in my case)

Add this
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
before calling
[[UIDevice currentDevice] setValue: ];

and

while ([[UIDevice currentDevice] isGeneratingDeviceOrientationNotifications]) {
    [[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications];
  }

before
return [Orientation getOrientation];
in AppDelegate's application supportedInterfaceOrientationsForWindow

All 4 comments

Alternative workaround (which is better in my case)

Add this
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
before calling
[[UIDevice currentDevice] setValue: ];

and

while ([[UIDevice currentDevice] isGeneratingDeviceOrientationNotifications]) {
    [[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications];
  }

before
return [Orientation getOrientation];
in AppDelegate's application supportedInterfaceOrientationsForWindow

@thehappycoder make a PR :D

As I saw there were no PR for this issue, I got the solution from @thehappycoder and created one. Hope you don't mind..! The pull request is the #247.

I still get this issue on 3.1.3. First workaround works

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sujay-bidchat picture sujay-bidchat  路  6Comments

balmasich picture balmasich  路  6Comments

sergio-solnet picture sergio-solnet  路  9Comments

RafaelHovhannisyan picture RafaelHovhannisyan  路  3Comments

shaikhussian picture shaikhussian  路  8Comments