OK修正しました。
UINavigationControllerを使用して、popToViewController:animated:ランドスケープビューからポートレートビューに移動すると、宛先ビューは正しく表示されますが、ステータスバーとUIKeyboardはランドスケープ構成を維持し、実際の混乱を引き起こします。
回避
策statusBarOrientationとリファレンスに関する何千もの推奨事項を読んだ後...
https: //developer.apple.com/library/content/releasenotes/General/RN-iOSSDK-6_0/index.html
「setStatusBarOrientation:animated:メソッドは完全に非推奨ではありません。最上位のフルスクリーンビューコントローラーのsupportedInterfaceOrientationsメソッドが0を返した場合にのみ機能するようになりました。これにより、呼び出し元はステータスバーの向きが一貫していることを確認する責任があります。」(ここのVytisに感謝します)
statusBarOrientationは、supportedInterfaceOrientationsが0を返す場合にのみ機能するため、推測が可能です。
statusBarOrientationが期待どおりでない場合は、1回のゼロリターンでそれが行われます(常に0を返す場合、ビューは回転しないため、次のようになります。
// if deviceOrientation is A (so I expect statusbarOrientation A
// but statusbarOrientation is B
// return 0
// otherwise
// return user interface orientation for A
- (NSUInteger)supportedInterfaceOrientations {
UIDeviceOrientation deviceOrientation = [[UIDevice currentDevice] orientation];
UIInterfaceOrientation statusBarOrientation =[UIApplication sharedApplication].statusBarOrientation;
if(deviceOrientation == UIDeviceOrientationPortrait || deviceOrientation == UIDeviceOrientationPortraitUpsideDown){
if(statusBarOrientation != UIInterfaceOrientationPortrait ||statusBarOrientation != UIInterfaceOrientationPortraitUpsideDown){
return 0;
}
}
// otherwise
return UIInterfaceOrientationMaskPortrait;
}
さて、viewDidAppearで(私を信じてください、私はキーボード通知が受信されたときでさえこの呼び出しを使用します:
[UIApplication sharedApplication].statusBarOrientation = UIInterfaceOrientationPortrait;
これで48時間以上の労働時間。皆さんのおかげで、これがしばらくお役に立てば幸いです。