【发布时间】:2017-09-05 13:07:38
【问题描述】:
我正在开发一个应用程序,实际上我的应用程序在选项卡/iPad 中显示横向和纵向。但是在平板电脑(iPad 工作正常)中,当我检查方向功能正常工作直到解锁设备时。当我将屏幕锁定在特定模式(如(纵向/横向))之后,设备在方向之前显示。不更新当前方向。
我点击了这个链接:https://github.com/yamill/react-native-orientation
这是我的代码:
componentWillMount(){
this.getOrientationtype()
}
getOrientationtype(){
//alert("Hello")
if(Platform.OS == 'ios'){ // to Identifying Android or iOS
if(aspectRatio>1.6){ // Code for Iphone
// alert("phone")
Orientation.lockToPortrait()
}
else{
Orientation.getOrientation((err, initial) => {
if(initial != 'UNKNOWN'){
this.setState({
orientation:initial
})
}
else{
this.setState({
orientation:'PORTRAIT'
})
}
});
}
}
else{
if(DeviceInfo.isTablet()){
// alert("android tab")
Orientation.getOrientation((err, initial) => {
if(initial != 'UNKNOWN'){
this.setState({
orientation:initial
})
}
else{
this.setState({
orientation:'PORTRAIT'
})
}
});
}
else{
Orientation.lockToPortrait()
}
}
}
请找出这个解决方案....我正在使用这个链接enter link description here
【问题讨论】:
标签: react-native react-native-android