Screen Orientation specific for one screen, but allow ALL for the rest

I have an app that I would like to make one specific screen orient to landscape for video, but the rest of the app should be ‘default’ or ALL or variable depending on which way the user holds the device. But if I set a screen to this:

ScreenOrientation.allowAsync(Expo.ScreenOrientation.Orientation.LANDSCAPE);

Then everything is locked to landscape, even if I then do:

ScreenOrientation.allowAsync(Expo.ScreenOrientation.Orientation.ALL);

Here is a snack example: https://snack.expo.io/@kellypacker/screen-orientation-locks-on-allowasync

It seems like it’s not really an ‘allow’, but more of a lock.

Is this possible to do this? Am I’m missing something?

Thanks for the help.

hi @kellypacker, changing screen orientation makes a system call to rotate the screen of the entire app. In order for you to change it for a particular screen, you will need to make a screen orientation change. (ie) user goes to screen A -> call allowAsync(landscape) -> user goes to screen B -> call allowAsync(portrait)

And yes, allowAsync is locking the screen orientations. We are changing the API in the upcoming SDK release to better reflect this behavior (ie) renaming the method to lockAsync

@quinlanj The approach you described is what I’m doing in the actual app.

I am getting reports that sometimes the orientation isn’t happening, but that is an issue for another day because it’s intermittent and I can’t pin it down.

Thanks for the reply.

1 Like

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.