我用于TabNavigation
我的应用程序.在某些屏幕中,我希望它仅在portrait
方向上显示,而其他屏幕则显示landscape
.我react-native-orientation
在屏幕上找到并尝试:
屏幕1
import React from "react";
import Orientation from 'react-native-orientation';
import { Text } from 'react-native'
export default Screen1 extends React.PureComponent{
componentDidMount(){
Orientation.lockToLandscape();
}
componentWillUnmount(){
Orientation.unlockAllOrientations();
}
render() {
return(<Text>Screen 1</Text>);
}
}
Run Code Online (Sandbox Code Playgroud)
屏幕2
import React from "react";
import Orientation from 'react-native-orientation';
import { Text } from 'react-native'
export default Screen2 extends React.PureComponent{
componentDidMount(){
Orientation.lockToPortrait();
}
componentWillUnmount(){
Orientation.unlockAllOrientations();
}
render() {
return(<Text>Screen 2</Text>);
}
}
Run Code Online (Sandbox Code Playgroud)
标签导航器
const AppNavigator = TabNavigator( {
Screen1: …
Run Code Online (Sandbox Code Playgroud)