Reputation: 1439
I'm a newbie in React Native and I cannot find a way to lock the view of a page in landscape mode. Is there a way to do that?
Thank you.
Upvotes: 7
Views: 7507
Reputation: 2808
Install: npm install react-native-orientation --save
in AppDelegate.m Add these two lines:
#import "../../node_modules/react-native-orientation/iOS/RCTOrientation/Orientation.h"
- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
return [Orientation getOrientation];
}
componentDidMount(){
Orientation.lockToLandscape();
}
Upvotes: 3
Reputation: 41
You want to have the app always be in landscape mode? Android or iOS?
There is a hardware mode that allows you to rotate your simulator. If you want to use lock the app in landscape there is a way using a node module. The below link should help. https://www.npmjs.com/package/react-native-orientation
Upvotes: 4