Solution 1 :
For Android
For Android platform all we need to do is navigate to AndroidManifest.xml file that lies inside android/app/src/main
path and add the property android:screenOrientation
with a value or portrait or landscape respectively. The property has to be added in xml element activity which is a child of application element.
Simply add it as shown below:
For iOS
For iOS platform we need to open Xcode, and select the desired orientation modes from the Device Orientation section. As shown below:
- Load the iOS part of your React Native project
- Navigate to tab General from the horizontal menu
- Go to down to Deployment Info section and check/uncheck the desired device orientation modes.
And you are set! Rebuild your project to verify that the changes are configured.
Problem :
Hi I want to know how to lock device orientation for React Native for both android and iOS. I need to lock the orientation once user rotate the device and application will lock with portrait or lanscape
Comments
Comment posted by npmjs.com/package/react-native-orientation-locker
Try this package
Comment posted by Akila Devinda
@DeSilva glad it helps