您的位置:首页 > Web前端 > React

react native 导入第三方连接库,Orientation.h file is not found

2016-11-17 09:03 591 查看
正确的执行步骤

1>npm install --save react-native-orientation

2>react-native link 自动将project和.a文件导入你的xcode 项目中,不需要手动导入

3>bulild,编译运行

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


 

参考:

http://facebook.github.io/react-native/docs/linking-libraries-ios.html#step-3

https://github.com/yamill/react-native-orientation
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐