0
私は反応したネイティブの向きに基づいてサンプルアプリケーションを開発しています。実際にオリエンテーションが働いています。私は風景モードを望んでいます。私は特定のページに行っていました。この状況では問題ありませんが、風景モードを表示していますが、デバイスをポートレートモードにしようとしています。肖像画。LandScapeがネイティブで作業していませんか? IOS/Androidデバイスオフモード時の自動回転
私はこのモジュールを使用すると、このコードを書いています:
VARの向きを=必要( '反応-ネイティブ向き');
class XOrating extends React.Component {
constructor(props){
super(props);
this.state={
HEIGHT:667,
WIDTH:375
}
}
componentWillMount(){
if(this.props.sportName == 'Pro Football'){
Orientation.lockToLandscape();
this.setState({
HEIGHT:375,
WIDTH:667
})
}
else{
Orientation.lockToPortrait();
}
}
_orientationDidChange(orientation) {
if (orientation == 'LANDSCAPE') {
Orientation.lockToLandscape();
//do something with landscape layout
} else if(orientation == 'PORTRAIT') {
//do something with portrait layout
Orientation.lockToLandscape();
}
}
componentWillUnmount() {
Orientation.getOrientation((err,orientation)=> {
console.log("Current Device Orientation: ", orientation);
});
Orientation.removeOrientationListener(this._orientationDidChange);
}
componentDidMount(){
Orientation.addOrientationListener(this._orientationDidChange);
}
render(){
return(
<Image source={{uri:this.state.ImgBackground}} style={{width:this.state.WIDTH,
height:this.state.HEIGHT, top:0, left:0}}>
)
}
module.exports = XOrating;
私はオートローテーション内のデバイスの中に隠れる