【发布时间】:2017-02-15 06:19:32
【问题描述】:
我正在使用 React 原生定向模块。我只需要一个屏幕的横向视图。所以在 componentDidMount() 中写了 loackToLandscape() ,回去的时候我写了 lockToProtrait()。
我的代码如下:
componentWillMount(){
if(this.props.sportName == 'Pro Football'){
Orientation.lockToLandscape();
this.setState({
HEIGHT:375,
WIDTH:667
})
}
else{
Orientation.lockToPortrait();
}
}
onBack(){
Orientation.lockToPortrait();
this.setState({
open:false
})
}
当 autorotation 为 false 时,它工作正常。但是,当我将设备更改为纵向时 autorotation 打开时,视图也会更改为纵向。但我希望它被锁定为横向。
【问题讨论】:
标签: reactjs react-native orientation