React native 如何动态设置推屏方向-反应本机导航

React native 如何动态设置推屏方向-反应本机导航,react-native,react-native-navigation,React Native,React Native Navigation,我想知道如何使用react native navigation动态更改推送屏幕的方向 我正在使用startSingleScreenApp,其应用程序样式为方向:“纵向”以强制纵向屏幕。我只想让其中一个屏幕使用“自动” 我尝试了以下方法: static navigatorStyle = { drawUnderTabBar: true, orientation: 'auto' }; 我也尝试过: componentWillMount() { this.props.navigato

我想知道如何使用react native navigation动态更改推送屏幕的方向

我正在使用startSingleScreenApp,其应用程序样式为方向:“纵向”以强制纵向屏幕。我只想让其中一个屏幕使用“自动”

我尝试了以下方法:

static navigatorStyle = {
   drawUnderTabBar: true,
   orientation: 'auto'
};
我也尝试过:

componentWillMount() {
   this.props.navigator.setStyle({
      orientation: 'auto'
   });
};
我甚至使用以下命令推到屏幕上:

...
navigatorStyle: {
  orientation:'auto'
}
...

甚至可以动态更改它吗?

可以通过使用React Native Orientation来实现。它将侦听React本机应用程序中的设备方向更改,并在每个屏幕上以编程方式设置首选方向。它适用于Android和iOS。有关更多详细信息,请查看以下链接:

您可以按如下方式使用它:


您可以在共享链接中找到详细的说明/指南。您可以根据需要添加相应的逻辑。希望对您有所帮助。

可以通过使用React Native Orientation来实现。它将侦听React本机应用程序中的设备方向更改,并在每个屏幕上以编程方式设置首选方向。它适用于Android和iOS。有关更多详细信息,请查看以下链接:

您可以按如下方式使用它:


您可以在共享链接中找到详细的说明/指南。您可以根据需要添加相应的逻辑。希望对您有所帮助。

我使用了此解决方案,但从纵向屏幕到横向屏幕的过渡不平滑,有点滞后,正确的方法是什么?我使用了此解决方案,但从纵向屏幕到横向屏幕的过渡不平滑,有点滞后,正确的方法是什么?
https://github.com/yamill/react-native-orientation
import Orientation from 'react-native-orientation';

// this locks the view to Portrait Mode. Need to add this in your screens 
 componentDidMount function
Orientation.lockToPortrait();
// this locks the view to Landscape Mode. Need to add this in your screens 
 componentDidMount function
 Orientation.lockToLandscape();