我真的想了解自动旋转在iOS5和iOS6中如何使用父视图和子视图控制器。
假设我有一个带有三个UIViewControllers的RootViewController Root View Controller将三个视图控制器作为子视图控制器,并负责交换它们UIViewControllers。 现在,我希望其中一个子视图控制器能够在所有界面方向上自动旋转,而另外两个只能使用纵向界面方向。
这可能吗?它是如何在iOS 5中完成的?和iOS 6?
我真的想了解所有的shouldAutorotateToInterfaceOrientation:supportedInterfaceOrientations preferredInterfaceOrientationForPresentation shouldAutorotate shouldAutomaticallyForwardRotationMethods方法。但我不能让这个工作:\ ........
答案 0 :(得分:0)
对于这两个视图(您希望仅在纵向模式下可用):
打开他们的View Controllers,并实现此方法:
- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation{
return UIInterfaceOrientationIsPortrait(toInterfaceOrientation); // don't rotate if it's not portrait.
// if you don't want the upside down portrait mode to be available as well, return the expression from below
// return toInterfaceOrientation == UIInterfaceOrientationPortrait;
}
这个实际上已被弃用,因此您也可能想要使用它:
- (BOOL) shouldAutorotate
{
return YES;
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
// if you want it to be also in upside down portrait mode, return the expression below
return UIInterfaceOrientationPortrait | UIInterfaceOrientationPortraitUpsideDown;
}