锁定设备方向 - React Native(Android)

Pro*_*mma 13 android orientation device-orientation react-native

我正在使用React Native 0.29并为Android开发.我正试图锁定设备方向.我需要的是以纵向模式锁定屏幕.我尝试使用此存储库https://github.com/yamill/react-native-orientation但它尚未支持RN 0.29.

有什么方法可以锁定设备方向吗?也许任何原生的Android黑客与Android工作室?

Fel*_*tim 25

只需将android:screenOrientation ="portrait"添加到AndroidManifest.xml中的活动即可.


Aak*_*del 2

有一个拉取请求可以在 0.29.2 及更高版本上工作: https://github.com/yamill/react-native-orientation/pull/85

如果你使用他的版本,它应该可以在 0.29.2 及更高版本上工作: https: //github.com/youennPennarun/react-native-orientation

脚步:

  1. 取消先前安装的链接rnpm unlink react-native-orientation

  2. rm -rf node_modules/react-native-orientation

  3. 在 package.json 中将 的条目编辑react-native-orientation为:

    "react-native-orientation": "youennPennarun/react-native-orientation"

  4. npm install

  5. react-native link react-native-orientation

此后事情应该会起作用。您可以跟踪 PR 的进度并在合并后切换到主存储库。