'How to lock Orientation for a particular screen in ios in react native?

I want to lock the orientation of my camera screen.

<Stack.Screen name="Camera" component={Camera} options={{ headerShown:false,orientation:'landscape'}}/>

This works fine in android but does not work on ios devices. Is there a way to solve this problem?



Solution 1:[1]

You can use below plugin for that https://www.npmjs.com/package/react-native-orientation-locker

Set up plugin and configure as mention in their doc and in react native side add below code which you want to Lock Screen portrait or landscape

import Orientation from 'react-native-orientation-locker';

useEffect(()=>{
   Orientation.lockToPortrait(); //this will lock the view to Portrait
   Orientation.lockToLandscape(); //this will lock the view to Landscape
})

EDIT

One more plugin is there you can set screen wise orientation https://www.npmjs.com/package/react-native-orientation In my one of the project this is also working . Hope your issue will be resolve on this.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1