ここや Google での検索中に出てこなかった、本当に簡単な質問です。UIView
他のすべてのビューが回転するときに、特定のオンを回転しないように制限するにはどうすればUIViewController
よいですか?
containerView.autoresizingMask = UIViewAutoresizingNone;
containerView.autoresizesSubviews = NO;
上記のコードは機能していないようです。
iOS6を使用しています。
ここや Google での検索中に出てこなかった、本当に簡単な質問です。UIView
他のすべてのビューが回転するときに、特定のオンを回転しないように制限するにはどうすればUIViewController
よいですか?
containerView.autoresizingMask = UIViewAutoresizingNone;
containerView.autoresizesSubviews = NO;
上記のコードは機能していないようです。
iOS6を使用しています。
iOS 6 では、回転を処理する方法が異なります。最上位のView Controllerで shouldAutorotate メソッドを使用する必要があります。以下、アップルからの引用
自動回転を一時的に無効にする場合は、方向マスクを操作してこれを行うことは避けてください。代わりに、最上位のビュー コントローラーで shouldAutorotate メソッドをオーバーライドします。このメソッドは、自動回転を実行する前に呼び出されます。NO が返された場合、回転は抑制されます。
次のようなものを試すことができます
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{
NSUInteger orientations = UIInterfaceOrientationMaskAllButUpsideDown;
if(self.window.rootViewController){
// CHECK FOR A PARTICULAR VIEW CONTROLLER
UIViewController *presentedViewController = [[(UINavigationController *)self.window.rootViewController viewControllers] lastObject];
orientations = [presentedViewController supportedInterfaceOrientations];
}
return orientations;
}