在iOS 7中强制使用Landscape ViewController [英] Force Landscape ViewController in iOS 7

查看:88
本文介绍了在iOS 7中强制使用Landscape ViewController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在纵向模式下有十多个ViewControllers,但无论设备的方向如何,我都需要在横向模式下强制使用一个。

I have more than ten ViewControllers in portrait mode, but I need to force a single one in Landscape mode regardless of the device´s orientation.

推荐答案

以下是解决方案:

1)将LandscapeViewController嵌入到子类的NavigationController中,并使用模态segue从PortraitViewController连接它。

1) Embed the LandscapeViewController in a subclassed NavigationController and connect it from your PortraitViewController using a modal segue.

2)子类UINavigationController

2) Subclass UINavigationController

LandscapeNavigationController.m

LandscapeNavigationController.m

-(BOOL)shouldAutorotate
{
    return NO;
}

-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskLandscapeLeft;
}

3)不要忘记解雇你的模态VC(在这种情况下来自我的Bar Buttom项目动作)

3) Don't forget to dismiss your modal VC (in this case from my Bar Buttom Item Action)

- (IBAction)goBack:(id)sender
{
    [self.navigationController dismissViewControllerAnimated:YES completion:nil];
}

这篇关于在iOS 7中强制使用Landscape ViewController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆