2017-07-18 6 views
3

私は、プレゼンテーションコントローラのプレゼンテーションの向きを変えずに、プレゼンテーションコントローラの一部がすべての方向をサポートできるようにします。 Xcode設定ですべての方向付けをサポートしています(上下を除く)。提示されたビューを回転させて、表示コントローラを表示する方向を固定する

私が提示ビューコントローラの向きを可能に使用していますビューコントローラ

ViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"VC"]; 
    vc.modalPresentationStyle = UIModalPresentationFormSheet; 
    [self presentViewController:vc animated:YES completion:nil]; 

コードを提示するために使用していますコード:動画を再生しながら

- (UIInterfaceOrientationMask)supportedInterfaceOrientations { 
    return UIInterfaceOrientationMaskAll; 
} 

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation{ 
    return YES; 
} 

あなたチューブアプリは、機能の同じ種類を提供それがどのように働いているのか?

ご協力いただきありがとうございます。

答えて

0

AppDelegate.m

- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window { 

if(_isAllModes) 
    return UIInterfaceOrientationMaskAll; 
else 
    return UIInterfaceOrientationMaskPortrait; 
} 

あなたのViewController。ローテーション:

[(AppDelegate*)([UIApplication sharedApplication].delegate) setIsAllModes:YES]; 
NSNumber *value = [NSNumber numberWithInt:UIInterfaceOrientationPortrait]; 
[[UIDevice currentDevice] setValue:value forKey:@"orientation"]; 
0

私は同様の問題がありましたが、プロジェクト設定はプログラムで適用した1つのViewController設定を上書きします。私はこの問題を解決するためにやったことは、あなたがすべての方向を有効にしたい場合は、例えば、より良いとにかくそれを行うことができ、プロジェクトの設定でのみ分の許容方向性を残し、

- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window //newUX 
{ 
    return UIInterfaceOrientationMaskAll; 
} 

以下のようにAppDelegate.mでそれを拡張しました。 1つの特定のシナリオでは、単にスタック内の最後のViewControllerは、「すべて」 - オンである私は、それは両方のビューコントローラの向きを変えている向きを変えていた場合

- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window //newUX 
{ 
    if([self.navController.viewControllers.lastObject isKindOfClass:[MyAllOrientationVC class]])//newUX 
     return UIInterfaceOrientationMaskAll; 
    else 
     return UIInterfaceOrientationMaskPortrait|UIInterfaceOrientationMaskLandscapeLeft|UIInterfaceOrientationMaskLandscapeRight; 
} 
+1

以下のように私は、また、ナビゲーションコントローラを使用していない場合は言って**表示されているビューコントローラ**方向の変更**表示されていないコントローラ**(表示されている設定で表示コントローラを表示していますスタイル**フォームシート**両方のビューコントローラが表示されるように) – user2493047

関連する問題