我正在开发一个React Native应用程序,由于应用程序的性质,通常只能使用纵向模式。在AndroidManifest.xml文件中使用以下标志将应用程序锁定为纵向模式:
android:screenOrientation="portrait"
现在我希望应用程序能够在应用程序的某个特定位置旋转。在React Native中,Modal组件似乎是正确的选择。Modal的配置如下:
<Modal
animationType="slide"
transparent={false}
supportedOrientations={['portrait', 'portrait-upside-down', 'landscape', 'landscape-left', 'landscape-right']}
>
<View style={styles.modal}>
<View>
<TouchableHighlight onPress={() => {
this.setState({
awareVisible: false
});
}}>
<Text>Hide Modal</Text>
</TouchableHighlight>
</View>
</View>
</Modal>
在iOS中,这个功能很好用,视图会旋转;但在Android上没有任何反应。我尝试创建了一个自定义的Modal组件,并在Android代码中捕获它,但对我来说也没有起作用。