【发布时间】:2014-10-07 10:44:43
【问题描述】:
我正在使用 UINavigationController 的子类来管理我的应用程序的旋转。
@implementation rotatingNavigationController
- (BOOL)shouldAutorotate
{
return [self.topViewController shouldAutorotate];
}
- (NSUInteger)supportedInterfaceOrientations
{
return [self.topViewController supportedInterfaceOrientations];
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return [self.topViewController preferredInterfaceOrientationForPresentation];
}
在我的第一个视图中,我只允许纵向:
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
我使用情节提要中创建的推送转场推送到新的视图控制器。新的视图控制器支持所有界面方向:
- (BOOL)shouldAutorotate
{
return YES;
}
- (NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationMaskAll;
}
新的视图控制器总是以纵向加载,无论设备处于什么方向。如果我在视图加载后将设备物理地切换到纵向模式并返回横向,它会正确旋转。我该如何纠正这个问题,我需要在视图加载时以设备所在的任何方向加载视图?
【问题讨论】:
-
自 iOS6 以来,我在 UINavigationController 内部的不同方向的视图控制器方面遇到了很多问题,并且没有找到合适的解决方案。我只是尽量避免这种情况并以模态方式呈现横向视图控制器。
标签: ios objective-c