2017-11-16 1 views
1

Hy、 このテーマは以前に尋ねられましたが、私はすべての解決策を検討しましたが、ランドスケープでの起動後、表示を肖像画で開始することはできません

私のアプリはすべて肖像画形式です。ランドスケープ形式のビューコントローラは1つだけです。

私は関係なく、デバイスの向き縦向きを強制するために、すべてのビューコントローラに次のコードを追加しました:デバイスはのViewControllerが正しく開くポートレートモードに設定されている場合は、そのデバイスがランドスケープモードに設定されている場合

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

-(BOOL)shouldAutorotate{ 
     return NO; 
} 
- (UIInterfaceOrientationMask)supportedInterfaceOrientations 
{ 
     return UIInterfaceOrientationMaskPortrait; 
} 

-(void)ViewDidLoad() 
{ 
     [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait]; 
} 

をアプリを開く前に、アプリはランドスケープでスプラッシュスクリーンを起動し、ビューの一部が切り取られた状態でビューコントローラーを開き、それをポートレートモードに回転し、画像の一部を切り取ったままにします。

アプリデリゲートで

enter image description here

- (UIInterfaceOrientationMask)supportedInterfaceOrientations 
{ 
     return UIInterfaceOrientationMaskPortrait;; 
} 

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window 
{ 
     return UIInterfaceOrientationMaskAllButUpsideDown; 
} 

そしてappDelegateでも、私は次のように追加のナビゲーションコントローラにビューコントローラを追加する前に:

[UIApplication sharedApplication].statusBarOrientation = UIInterfaceOrientationPortrait; 
[[UIDevice currentDevice] setValue:[NSNumber numberWithInteger:UIDeviceOrientationPortrait] forKey:@"orientation"]; 

感謝あなたはその問題に関するアドバイスをしています。

不明な点がある場合や、必要な情報が必要な場合は、私に知らせてください。

+0

チェックこのhttps://stackoverflow.com/questions/47274111/force-landscape-when-orientation-is-locked/47274224#47274224 –

+0

私はすでにそれを使用しています:[[UIDevice currentDevice]のsetValue:[ NSNumber numberWithInteger:UIDeviceOrientationPortrait] forKey:@ "orientation"]; – coder

答えて

1

これはiOS 11以来の新しいことです。私は自動回転を許可するが、それは肖像画のみをサポートすることで修正しました。

(BOOL)shouldAutorotate{ 
     return YES; 
} 
(UIInterfaceOrientationMask)supportedInterfaceOrientations 
{ 
    return UIInterfaceOrientationMaskPortrait; 
} 
+0

残念ながら、それは問題を解決しなかった、それはまだクリップとして表示されます。 – coder

関連する問題