AbhinavVinay
AbhinavVinay

Reputation: 303

UINavigation controller doesn't open in landscape mode

I am loading a UIViewController the following way:

-(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 is a UIViewController that creates a UITableView to get the input from the user. When I load it using a UINavigationController it refuses to open in Landscape mode. But if I load it directly to CCDirector the following way it opens properly in landscape.

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

I use the following inside NewSignInView:

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

So something is preventing the UINavigationController from opening up in landscape mode. Can anyone help me in any way on trying to figure out what is causing the problem?

Thanks

Upvotes: 0

Views: 110

Answers (1)

scrat84
scrat84

Reputation: 195

try following in your shouldAutorotateToInterfaceOrientation: method:

return UIInterfaceOrientationIsLandscape(interfaceOrientation);

So your Controller supports both rotations, not only LandscapeRight. Make sure the ViewController with the logIn-Method returns YES in shouldAutorotateToInterfaceOrientation.

Hope this helps. Besides i would make one suggestion: Don't name your ViewController NewSignInView with out Controller to avoid confusion. If it was only a quick and diry example - never mind.

greets

Upvotes: 1

Related Questions