2017-02-13 14 views
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; 

私はオートローテーション内のデバイスの中に隠れる

答えて

0

はい最後に、私は私が.....

を私のミスを何をしていましたが、ちょうど私が両方2を追加するときに風景モードに合わせたいお勧めしてくださいAppDelegate.mファイル内の行と、次にxコードを消去して実行します。

#import "../../node_modules/react-native-orientation/iOS/RCTOrientation/Orientation.h" 


- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window { 
    return [Orientation getOrientation]; 
    } 
関連する問題