2016-07-20 11 views
1

私はポートレートモードのみのアプリを持っています。ランドスケープモードに強制する必要があるView Controllerが1つしかないため(顧客の署名ビュー)、顧客が署名できる余地が増えます。1つのUIViewControllerで強制的に風景を表示

1つのViewControllerを強制的にランドスケープモードで表示できます。残りを肖像画に残していますか?

私はポートレートにアプリの一般的な展開の情報を設定しようとしている

、風景左

enter image description here

そして、署名の表示

- (BOOL)shouldAutorotate { 
    return YES; 
} 

を返すNOにこのコードを使用して他のすべてのView Controllerではです。しかし、それはうまくいかないようでした。

私も可能です。この

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
    return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft); 
} 

が含まれて?

+0

これを試しましたか?http://stackoverflow.com/questions/26357162/how-to-force-view-controller-orientation-in-ios-8? –

+0

@TejaNandamuri私はそれを試してみました。しかし、その見方は空です。私は、プログラムで作成されたビューが追加されたViewControllerのストーリーボードを使用しています。 –

+0

ありがとうございますこれを確認してくださいhttps://stackoverflow.com/questions/38308919/unable-to-force-uiviewcontroller-orientation/38308987#38308987 –

答えて

0

UIViewControllerがナビゲーションコントローラのルートコントローラで、ナビゲーションコントローラにコードを配置する必要がある場合は、次のコードが欠落しているだけです。これが幸運を助けることを願っています。

- (UIInterfaceOrientationMask)supportedInterfaceOrientations 
{ 
    return UIInterfaceOrientationMaskLandscape; 
} 
+0

その半加工。 Autolayoutはすべての要素が間違ってレイアウトされているため、ウィンドウの外に出ているようです。さらに、景観を残すと、他のすべての景色が景観に残っています。 –

+0

あなたのストーリーボードのイメージは、使用する制約と、景色に間違って配置されているように見えます。私は 'supportedInterfaceOrientations'と 'shouldAutorotate'を設定し、vcAはポートレートで表示され、vcBはランドスケープに表示されます。私は ' self.navigationController dismissViewControllerAnimated'を実行してvcBからvcAにポップします。 – JingJingTao

0

そのは私のために働い方法です、次の署名のビューコントローラ

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
    [[UIDevice currentDevice] setValue:[NSNumber numberWithInteger:UIInterfaceOrientationLandscapeLeft] forKey:@"orientation"]; 
} 

-(void)viewWillDisappear:(BOOL)animated 
{ 
    [super viewWillDisappear:animated]; 
    [[UIDevice currentDevice] setValue:[NSNumber numberWithInteger:UIInterfaceOrientationPortrait] forKey:@"orientation"]; 
} 
0

にこのコードを試してください: -

-(UIInterfaceOrientationMask)supportedInterfaceOrientations 
{ 
    return UIInterfaceOrientationMaskLandscapeLeft; 
} 

and 

- (BOOL)shouldAutorotate { 
    return NO; 
} 

もう一つの方法は、prepareForSegue向きを定義することで、固定必要なVCの方向付けを行い、そのVCのshouldAutorotateをNOに設定します。

上記のコードがうまく動作しない場合は教えてください。

関連する問題