支持一个UIView控制器的横向和UINavigationController堆栈中其他UIView控制器的纵向



我有 4 个 UIViewControllers -- 命名为 ControllerA,ControllerB,ControllerC,ControllerD。

其中 ControllerA 是 UINavigationStack 中的 RootViewController。

ControllerA *ca = [[ControllerA alloc]initWithNibName:@"ControllerA" bundle:nil];
UINavigationController *nv = [[UINavigationController alloc]initWithRootViewController:ca];
self.window.rootViewController = nv;

推动控制器B之后,它们都处于potrait中,但是问题来了,我希望控制器C在横向中。

我已经经历了许多代码,但任何令人满意或有效的解决方案,但我确实设法通过沿角度转换视图来旋转它——

[[UIApplication sharedApplication]]setStatusBarOrientation:UIInterfaceOrientationLandscapeRight
animated:YES];
self.view.transform = CGAffineTransformMakeRotation(M_PI/2);

但是现在我想在控制器C上呈现模式ControllerD,如果它通过一些旋转,它不会横向出现,它会干扰所有其他视图控制器转换。

做了这么多之后,我又回到了同样的问题,即通过一些记录的方法在景观中制作ControllerC。

对于纵向模式 VC,

#pragma mark iOS 5 Orientation Support
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
     return UIInterfaceOrientationIsPortrait(interfaceOrientation);
}
#pragma mark iOS 6 Orientation Support
-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskPortrait;
}

对于横向模式 VC,

#pragma mark - iOS 5.0 and up Rotation Methods
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return UIInterfaceOrientationMaskLandscape;
}
#pragma mark - iOS 6.0 and up Rotation Methods
- (NSUInteger)supportedInterfaceOrientations;
{
    return UIInterfaceOrientationMaskLandscape;
}

最新更新