【问题标题】:UINavigation controller doesn't open in landscape modeUINavigation 控制器未在横向模式下打开
【发布时间】:2012-05-07 17:37:34
【问题描述】:

我正在通过以下方式加载UIViewController

-(void)logIn
{
    NewSignInView *viewController = [[[NewSignInView alloc] init] autorelease];

    UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:viewController];
    [self presentModalViewController:navController animated:YES];
    [navController release];

    [UIView animateWithDuration:0.3
                          delay:0
                        options:UIViewAnimationCurveEaseOut
                     animations:^{ self.view.alpha = 0; }
                     completion:^(BOOL finished){ }];
}

NewSignView 是一个UIViewController,它创建一个UITableView 来获取用户的输入。当我使用UINavigationController 加载它时,它拒绝以横向模式打开。但是,如果我按照以下方式将其直接加载到CCDirector,它将在横向中正确打开。

[[[CCDirector sharedDirector] openGLView] addSubview:viewController.view];

我在NewSignInView中使用以下内容:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}

所以有些东西阻止了UINavigationController 在横向模式下打开。任何人都可以以任何方式帮助我找出导致问题的原因吗?

谢谢

【问题讨论】:

    标签: iphone ios uiview uinavigationcontroller cocos2d-iphone


    【解决方案1】:

    在你的 shouldAutorotateToInterfaceOrientation: 方法中尝试以下操作:

    return UIInterfaceOrientationIsLandscape(interfaceOrientation);
    

    所以您的控制器支持两种旋转,而不仅仅是 LandscapeRight。 确保带有 logIn-Method 的 ViewController 在 shouldAutorotateToInterfaceOrientation 中返回 YES。

    希望这会有所帮助。 此外,我会提出一个建议:不要在没有 Controller 的情况下将 ViewController 命名为 NewSignInView 以避免混淆。如果这只是一个简单而简单的例子 - 没关系。

    问候

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-07-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多