我正在开发 IOS React Native 项目(使用带有裸工作流程的 expo)。 默认情况下,我的应用程序使用纵向模式,但有时我需要将屏幕方向更改为横向模式。我使用 expo-screen-orientation 库来更改屏幕方向。当应用程序更改屏幕方向时,我在发布的应用程序中遇到问题,尽管在 Debug模式下它工作得很好(IOS模拟器/IOS设备)。在 Release模式下,我遇到了切屏问题。请检查附件中的照片
import { StatusBar } from 'expo-status-bar';
import {StyleSheet, Text, View, Button} from 'react-native';
import * as ScreenOrientation from 'expo-screen-orientation';
export default function App() {
const foo = async()=>{
await ScreenOrientation.lockAsync(ScreenOrientation.OrientationLock.LANDSCAPE_LEFT);
}
return (
<View style={styles.container}>
<Text style={{paddingTop:50}}>Open up App.js to start working on your app!</Text>
<Button title="Rotate" onPress={foo}/>
<StatusBar style="auto" />
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#cccccc',
alignItems: 'center',
justifyContent: 'flex-start',
},
});
横向模式,带切屏
最佳答案
expo SDK 43 的 expo-updates 存在错误,您需要将 package.json 中的 expo-updates 更新到 v0.10.15,然后 npm install 并运行 pod install。这为我解决了这个问题。其他人指出,将 expo 降级到 SDK 42 也解决了问题。
更多信息请点击这里: https://github.com/expo/expo/issues/14967#issuecomment-966811190
关于ios - React Native,面向展览屏幕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69901242/