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

unlockAllOrientations does not work

Open olinations opened this issue 6 years ago • 1 comments

I created a screen and upon loading I lock it to landscape mode. After that I cannot unlock it, it remains in landscape mode. I can change it to lock in portrait mode after being in landscape mode and that works, but Orientation.unlockAllOrientations() never works.

To test I even created a button to unlock orientation, simply calling Orientation.unlockAllOrientations() when pressed and it does not work. orientation remains locked.

I am using ReactNative 0.59.x

olinations avatar Oct 15 '19 06:10 olinations

@olinations I ran into the same issue. I'm using Wix React Native Navigation for navigation and I realized that I needed to enable both orientations in the settings. That may not help you but it might help others who run into this issue.

Navigation.events().registerAppLaunchedListener(async () => {
    Navigation.setDefaultOptions({
        ...
        layout: {
            orientation: ["portrait", "landscape"] // <-- Enable both orienations
        },
        ...
    })
    Navigation.setRoot({
        ...
    })
})

daveyjones avatar Nov 08 '19 16:11 daveyjones