Quantcast
Channel: Active questions tagged react-native+ios - Stack Overflow
Viewing all articles
Browse latest Browse all 16552

react navigation open screen in landscape

$
0
0

I am using react-navigation v5. All my app is in portrait but 2 screens in landscape mode. I have a custom player and youtube embedded player which should rotate. My custom player can be only in landscape mode. My player is a modal screen. I want it to be in landscape mode only and other screens under it in portrait how can I do that? Because right now my whole app changes orientation with react-native-orientation-locker lib.

example code:

export default class Player extends Component<PlayerProps, PlayerState> {  state = {    paused: false,    progress: 0,    duration: 0,    currentQuality: '',  };...  componentDidMount() {    // this locks the view to Portrait Mode    Orientation.lockToLandscape();    StatusBar.setHidden(true);    // this locks the view to Landscape Mode    // Orientation.lockToLandscape();    // this unlocks any previous locks to all Orientations    // Orientation.unlockAllOrientations();    Orientation.addOrientationListener(this._orientationDidChange);  }  _orientationDidChange = (orientation: string) => {    if (orientation === 'LANDSCAPE') {      // do something with landscape layout    } else {      // do something with portrait layout    }  };  componentWillUnmount() {    Orientation.lockToPortrait();    StatusBar.setHidden(false);    Orientation.getOrientation((err, orientation) => {      console.log(`Current Device Orientation: ${orientation}`);    });    // Remember to remove a listener    Orientation.removeOrientationListener(this._orientationDidChange);  } ...  render() {    return (...);  }}

Viewing all articles
Browse latest Browse all 16552

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>