我在使用 Landscape
将屏幕更改为 expo-screen-orientation
时遇到问题。我有一个使用 ImageViewer
显示图像的组件。当我在 Android
时它有效,但当我在 iOS
时它不起作用。我该如何解决。我所做的是我调用了我的 2 函数 unlockScreenToDefault
和 lockScreenToPortraitOrientation
:
componentDidMount() {
unlockScreenToDefault().then();
}
componentWillUnmount() {
lockScreenToPortraitOrientation().then();
}
在 2 个函数中:
const lockScreenToPortraitOrientation = async () => {
await ScreenOrientation.lockAsync(ScreenOrientation.OrientationLock.PORTRAIT);
};
const unlockScreenToDefault = async () => {
await ScreenOrientation.unlockAsync();
};