加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-15 08:20:08 所属栏目:百科 来源:网络整理
导读:正确的执行步骤 1 npm install--savereact-native-orientation 2react-native link 自动将project和.a文件导入你的xcode 项目中,不需要手动导入 3bulild,编译运行 iOS: 1.用Xcode打开项目,右键点击项目名称,选择 “Add Files to ‘项目名’ “ ; 2.找到

正确的执行步骤

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读