これはおそらく、Apple が UIViewController の方向を管理する方法を変更したために発生しています。iOSiOS6 shouldAutorotateToInterfaceOrientation
コンテナ ( などUINavigationController
) は、自動回転する必要があるかどうかを決定するために、子を参照しません。デフォルトでは、アプリとビュー コントローラーでサポートされているインターフェイスの向きはUIInterfaceOrientationMaskAll
、iPad イディオムとUIInterfaceOrientationMaskAllButUpsideDown
iPhone イディオムに対して に設定されています。
同じことに関する詳細については、このリンクにアクセスしてください
。以下に、方向の変更を処理するためのカテゴリを作成しました。
SO iOS6 で UIViewController の方向を管理するために、さらに 2 つのメソッドを実装する必要があります。
IOS6 で導入 向きの変更を許可
- (BOOL)shouldAutorotate
{
return YES;
}
デバイスでサポートされる方向の数を返します
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskAll;
}
次に、取得している方向を確認します。
編集: このコードをルート ViewController として追加された FirstViewController に配置します。これは、UIViewController が方向を判断するのに役立ちます。
@implementation UINavigationController (RotationIn_IOS6)
-(BOOL)shouldAutorotate
{
return [[self.viewControllers lastObject] shouldAutorotate];
}
-(NSUInteger)supportedInterfaceOrientations
{
return [[self.viewControllers lastObject] supportedInterfaceOrientations];
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return [[self.viewControllers lastObject] preferredInterfaceOrientationForPresentation];
}
@end
お役に立てれば幸いです。