Hy、 このテーマは以前に尋ねられましたが、私はすべての解決策を検討しましたが、ランドスケープでの起動後、表示を肖像画で開始することはできません
私のアプリはすべて肖像画形式です。ランドスケープ形式のビューコントローラは1つだけです。
私は関係なく、デバイスの向き縦向きを強制するために、すべてのビューコントローラに次のコードを追加しました:デバイスはのViewControllerが正しく開くポートレートモードに設定されている場合は、そのデバイスがランドスケープモードに設定されている場合
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return UIInterfaceOrientationMaskPortrait;
}
-(BOOL)shouldAutorotate{
return NO;
}
- (UIInterfaceOrientationMask)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
-(void)ViewDidLoad()
{
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait];
}
をアプリを開く前に、アプリはランドスケープでスプラッシュスクリーンを起動し、ビューの一部が切り取られた状態でビューコントローラーを開き、それをポートレートモードに回転し、画像の一部を切り取ったままにします。
アプリデリゲートで:
- (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"];
感謝あなたはその問題に関するアドバイスをしています。
不明な点がある場合や、必要な情報が必要な場合は、私に知らせてください。
チェックこのhttps://stackoverflow.com/questions/47274111/force-landscape-when-orientation-is-locked/47274224#47274224 –
私はすでにそれを使用しています:[[UIDevice currentDevice]のsetValue:[ NSNumber numberWithInteger:UIDeviceOrientationPortrait] forKey:@ "orientation"]; – coder