这是一个非常简单的问题,在搜索过程中和谷歌上没有出现在我身上。如果所有其他观看的内容,如何限制UIView
上的某个UIViewController
不旋转?
containerView.autoresizingMask = UIViewAutoresizingNone;
containerView.autoresizesSubviews = NO;
上面的代码似乎不起作用。
我正在使用iOS 6.
答案 0 :(得分:1)
iOS 6有不同的处理旋转方式。您必须在最顶层的视图控制器上使用shouldAutorotate方法。以下是Apple的报价
如果要暂时禁用自动旋转,请避免操作方向遮罩来执行此操作。而是覆盖最顶层视图控制器上的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;
}