世博会改成横屏?

时间:2021-03-25 10:00:13

标签: react-native expo

我在使用 Landscape 将屏幕更改为 expo-screen-orientation 时遇到问题。我有一个使用 ImageViewer 显示图像的组件。当我在 Android 时它有效,但当我在 iOS 时它不起作用。我该如何解决。我所做的是我调用了我的 2 函数 unlockScreenToDefaultlockScreenToPortraitOrientation

  componentDidMount() {
    unlockScreenToDefault().then();
  }

  componentWillUnmount() {
    lockScreenToPortraitOrientation().then();
  }

在 2 个函数中:

const lockScreenToPortraitOrientation = async () => {
  await ScreenOrientation.lockAsync(ScreenOrientation.OrientationLock.PORTRAIT);
};

const unlockScreenToDefault = async () => {
  await ScreenOrientation.unlockAsync();
};

0 个答案:

没有答案
相关问题