@H_404_0@
iOS:
1.用Xcode打开项目,右键点击项目名称,选择 “Add Files to ‘项目名’ “ ;
2.找到路径文件: 项目文件夹/node_modules/react-native-orientation/RCTOrientation ,将该文件添加上;
3.然后重新运行项目;
Android:
用法
componentWillMount() { // 判断横竖屏幕 var initial = Orientation.getInitialOrientation(); if (initial === 'PORTRAIT') { //do stuff } else { //do other stuff } // 只允许竖屏 Orientation.lockToPortrait(); //只允许横屏 Orientation.lockToLandscape(); } |
Functions
lockToPortrait()
lockToLandscape()
lockToLandscapeLeft()
lockToLandscapeRight()
unlockAllOrientations()
getOrientation(function(err,orientation)
返回的结果有LANDSCAPE
PORTRAIT
UNKNOWN
PORTRAITUPSIDEDOWN
getSpecificOrientation(function(err,specificOrientation)
返回的结果有LANDSCAPE-LEFT
LANDSCAPE-RIGHT
PORTRAIT
UNKNOWN
PORTRAITUPSIDEDOWN
@H_404_0@参考: @H_404_0@http://facebook.github.io/react-native/docs/linking-libraries-ios.html#step-3
@H_404_0@https://github.com/yamill/react-native-orientation