我有UINavigationController
堆栈中的所有UIViewController
都是纵向的,除了最后一个横向。我当前的实现显示最后一个视图控制器在纵向上推动,但我可以旋转到横向,而不能旋转回肖像。 如何在推动视图时强制旋转到横向?iOS 6 - 在UINavigationController中强制旋转UIViewController
我UINavigationController
子类:
@interface RotationViewController : UINavigationController
@end
@implementation RotationViewController
- (BOOL)shouldAutorotate
{
return YES;
}
- (NSUInteger)supportedInterfaceOrientations
{
if (self.topViewController.class == [LoadingViewController class])
{
return UIInterfaceOrientationMaskLandscape;
}
return UIInterfaceOrientationMaskPortrait;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
if (self.topViewController.class == [LoadingViewController class])
{
return UIInterfaceOrientationLandscapeLeft;
}
return UIInterfaceOrientationPortrait;
}
@end
,我想景观仅视图控制器:
@implementation LoadingViewController
- (BOOL)shouldAutorotate
{
return YES;
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscape;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationLandscapeLeft;
}
@end
其他视图控制器没有实现任何的这些方法。
它的工作原理(我只是从我的导航控制器supportedInterfaceOrientation返回0),但我一直在寻找如何触发自动旋转时的答案推动视图。这个解决方案更多是一个招... – 2013-02-28 06:14:38
适合重新定向屏幕!但由于某种原因,状态栏仍处于最高位置。当我重新调整设备以匹配屏幕时,状态栏会转到正确的位置,但是当我回到原始纵向时,屏幕会变成肖像。 (这些都没有受到'supportedInterfaceOrientation'存在/缺失的影响。) – JohnK 2013-06-21 00:40:12