我正在做IOS React Native项目(使用expo和纯工作流程)。默认情况下,我的应用程序使用纵向模式,但有时需要将屏幕方向更改为横向模式。我使用expo- screen -orientation库来改变屏幕方向。当应用程序改变屏幕方向时,我在已发布的应用程序中遇到了问题,尽管在调试模式下它是完美的( IOS模拟器/ IOS设备)。在释放模式下,我遇到了剪切屏幕的问题。请检查附件中的照片
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',
},
});

横向模式,带裁切屏幕

发布于 2021-11-13 05:20:34
expo SDK 43的expo更新有一个bug,你需要在你的package.json中更新expo更新到v0.10.15,然后npm安装并运行pod install。这为我解决了这个问题。其他人指出,将expo降级到SDK 42也解决了问题。
更多信息请点击此处:https://github.com/expo/expo/issues/14967#issuecomment-966811190
https://stackoverflow.com/questions/69901242
复制相似问题