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

前端之家收集整理的这篇文章主要介绍了react native 导入第三方连接库,Orientation.h file is not found前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

正确的执行步骤

1>npm install--savereact-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)

返回的结果有LANDSCAPEPORTRAITUNKNOWNPORTRAITUPSIDEDOWN

  • getSpecificOrientation(function(err,specificOrientation)

返回的结果有LANDSCAPE-LEFTLANDSCAPE-RIGHTPORTRAITUNKNOWNPORTRAITUPSIDEDOWN


参考:

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

https://github.com/yamill/react-native-orientation

猜你在找的React相关文章