我正在開發一個應用程序,其實我的應用程序顯示橫向和標籤/ iPad中的肖像。但在平板電腦(iPad的工作正常),當我檢查方向功能工作正常,直到解鎖設備。當我鎖定屏幕像特定模式(肖像/風景)之後,該設備顯示方向前顯示。不更新目前的方向。方向未更新解鎖設備後在react-native- android
我跟着這個鏈接: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
呀真的非常感謝........ – Lavaraju