我正在开发一个反应本机应用程序,由于应用程序的性质,它通常被锁定在人像上。该应用程序在AndroidManifest.xml中使用以下标志锁定为肖像画
android:screenOrientation="portrait"现在我想让应用程序能够在应用程序中的某个位置旋转。模式组件在反应-本机似乎是正确的选择。该模式配置如下:
<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中,这很好,视图将旋转,而在安卓系统中,它什么也不做。我试着创建一个定制的Modal组件,并在Android代码中捕获它,但这对我也不起作用。
发布于 2019-10-07 14:35:03
你可以用反应-本土化 .因为这个项目似乎不再被维护,所以最好使用这个叉:反应-本机定位-储物柜
有了它,您只需要设置这样的东西,当您需要它时:
Orientation.unlockAllOrientations(); //this will unlock the view to all Orientations
Orientation.lockToPortrait(); //this will lock the view to Portrait
Orientation.lockToLandscapeLeft(); //this will lock the view to Landscape我还在我的应用程序中使用过它,该应用程序被迫采用肖像模式。但我需要景观模式来查看图像画廊的图像。在这两个方面都很好: Android和IOS.。
希望这能帮到你。
https://stackoverflow.com/questions/48221282
复制相似问题