UINavigationController
アプリでコンテンツを表示するために を使用します。コントローラーを別の辞書に保持し、ユーザーの操作時に、ナビゲーション コントローラーに適切な をロードしますUIViewContoller
。各View Controllerは、
- (BOOL)shouldAutoRotate;
と
- (NSUInteger)supportedInterfaceOrientations;
しかし、次のようにView ControllerをNavigation Controllerに設定しようとすると:
[self setViewControllers:[NSArray arrayWithObject:controller] animated:NO];
アプリケーションは、コントローラーのサポートされている向きに基づいて回転しません
たとえば、電話は横向きで、View Controller は縦向きのみをサポートしています。デバイスを縦向きに回転させるにはどうすればよいですか?
コード: 私のナビゲーション コントローラーのサブクラス
- (BOOL)shouldAutorotate{
return [[self topViewController] shouldAutorotate];
}
- (NSUInteger)supportedInterfaceOrientations{
return [[self topViewController] supportedInterfaceOrientations];
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentatio{
return [[self topViewController] preferredInterfaceOrientationForPresentation];
}
私のコントローラー:
- (BOOL)shouldAutorotate{
return YES;
}
- (NSUInteger)supportedInterfaceOrientations{
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
return UIInterfaceOrientationMaskPortrait;
}
return UIInterfaceOrientationMaskAll;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{
return UIInterfaceOrientationPortrait;
}
ドキュメントには、 を呼び出すsupportedInterfaceOrientations
にshouldAutorotate
は YES を返す必要があると記載されています。
何か案は??