【发布时间】:2021-12-22 08:12:22
【问题描述】:
我正在开发 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',
},
});
横向模式,带切屏
【问题讨论】:
标签: ios react-native expo screen-orientation