在横向反应导航打开屏幕

问题描述

我正在使用react-navigation v5。我所有的应用程序均为纵向模式,但横向模式为2个屏幕。我有一个应该旋转的自定义播放器和youtube嵌入式播放器。我的自定义播放器只能处于横向模式。我的播放器是模式屏幕。我希望它仅处于横向模式,并且肖像下的其他屏幕该怎么做?因为现在我的整个应用使用react-native-orientation-locker lib更改了方向。

示例代码


export default class Player extends Component<PlayerProps,PlayerState> {
  state = {
    paused: false,progress: 0,duration: 0,currentQuality: '',};

...

  componentDidMount() {
    // this locks the view to Portrait Mode

    Orientation.lockToLandscape();
    StatusBar.setHidden(true);

    // this locks the view to Landscape Mode
    // Orientation.lockToLandscape();

    // this unlocks any prevIoUs locks to all Orientations
    // Orientation.unlockAllOrientations();

    Orientation.addOrientationListener(this._orientationDidChange);
  }

  _orientationDidChange = (orientation: string) => {
    if (orientation === 'LANDSCAPE') {
      // do something with landscape layout
    } else {
      // do something with portrait layout
    }
  };

  componentwillUnmount() {
    Orientation.lockToPortrait();
    StatusBar.setHidden(false);
    Orientation.getorientation((err,orientation) => {
      console.log(`Current Device Orientation: ${orientation}`);
    });

    // Remember to remove a listener
    Orientation.removeOrientationListener(this._orientationDidChange);
  }

 ...

  render() {
    return (...);
  }
}


解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)