我有十多个ViewController在竖屏模式下,但是我需要强制一个单独的ViewController在横屏模式下运行,而不考虑设备的方向。
我有十多个ViewController在竖屏模式下,但是我需要强制一个单独的ViewController在横屏模式下运行,而不考虑设备的方向。
这里是解决方案:
1)将LandscapeViewController嵌入子类化的NavigationController中,并使用模态segue从PortraitViewController连接它。
2)子类化UINavigationController
LandscapeNavigationController.m
-(BOOL)shouldAutorotate
{
return NO;
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscapeLeft;
}
3) 别忘了关闭你的模态 VC(在这种情况下是从我的 Bar Buttom Item Action 中)
- (IBAction)goBack:(id)sender
{
[self.navigationController dismissViewControllerAnimated:YES completion:nil];
}