(React Native)在风景中锁定屏幕

时间:2015-09-14 18:00:49

标签: react-native

我是React Native的新手,我找不到在横向模式下锁定页面视图的方法。 有没有办法做到这一点?

谢谢。

2 个答案:

答案 0 :(得分:4)

您希望应用始终处于横向模式吗? Android还是iOS?

有一种硬件模式可以让您旋转模拟器。 如果您想在景观中使用锁定应用程序,则可以使用节点模块。 以下链接应该有所帮助。 https://www.npmjs.com/package/react-native-orientation

答案 1 :(得分:0)

安装:npm install react-native-orientation --save

在AppDelegate.m中

添加以下两行:

#import "../../node_modules/react-native-orientation/iOS/RCTOrientation/Orientation.h"

- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
    return [Orientation getOrientation];
  }

componentDidMount(){


     Orientation.lockToLandscape();  


 }
相关问题