仅在一个视图控制器上更改方向,将其他视图控制器锁定为纵向模式(xcode 6.2)

时间:2015-04-10 07:10:04

标签: objective-c xcode ios8 orientation

我已经使用AMSSlideMenuController来创建我的主VC

@interface LoggedIn_MainVC : AMSlideMenuMainViewController
@end

在App Delegate中我使用:

创建它
//start first vc
    self.mainVC = [[LoggedIn_MainVC alloc] init];
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

在LoggedIn_MainVC中,我使用AMSSlideMenuTableViewController创建左右菜单,如下所示:

@interface LeftMenuVC : AMSlideMenuLeftTableViewController

并且它们都在LoggedIn_MainVC中实例化:

*******************************/
self.leftMenu = [[LeftMenuVC alloc] initWithNibName:@"LeftMenuVC" bundle:nil];
self.rightMenu = [[RightMenuVC alloc] initWithNibName:@"RightMenuVC" bundle:nil];
/*******************************

在左侧菜单中,我有StartPageView,VideoPageView和SettingsView。我想将所有其他视图锁定为纵向模式,VideoView除外。 LeftMenuVC:

#pragma mark - TableView Delegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
- {UINavigationController *nvc;

UIViewController *rootVC;
switch (indexPath.row) {
    case 0:
    {
        rootVC = [[VCLoggedIn_StartPage alloc] initWithNibName:@"VCLoggedIn_StartPage" bundle:nil];
    }
        break;
    case 1:
    {
        rootVC = [[VCLoggedIn_Levels alloc] initWithNibName:@"VCLoggedIn_Levels" bundle:nil];
    }
        break;
    case 2:
    {
        rootVC = [[VCLoggedIn_Videos alloc] initWithNibName:@"VCLoggedIn_Videos" bundle:nil];
    }
        break;
    case 3:
    {
        rootVC = [[VCLoggedIn_Settings alloc] initWithNibName:@"VCLoggedIn_Settings" bundle:nil];
    }
        break;

    default:
        break;
}
nvc = [[UINavigationController alloc] initWithRootViewController:rootVC];

[self openContentNavigationController:nvc];
}

我在Appdelegate中使用

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window 
{
return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight; 
}

和视频:

-(BOOL)shouldAutorotate {
return YES;
} 
- (NSUInteger) supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight;
}

对于OtherViews:

-(BOOL)shouldAutorotate {
return YES;
}
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait;
}

所有观点的表现都相同(横向和纵向)。但是我发现当我将此定向模式放在LoggedIn_MainVC(mainView控制器)中时:

- (NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight;
}
- (BOOL)shouldAutorotate
{
return YES;
}

所有其他视图的行为方式与LoggedInMainVC中的此函数(supportedInterfaceOrientations)的定义方式相同。当我更改为UIInterfaceOrientationMaskPortrait时,所有视图都只有纵向模式,反之亦然。他们自己对supportedInterfaceOrientations的定义不起作用。 我错过了什么或做错了什么。 请帮助我

1 个答案:

答案 0 :(得分:0)

- (NSUInteger) application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
     return UIInterfaceOrientationMaskLandscape;
}
videoView

使其成为风景