Where can I set supported UINavigationControllersOrientations?

I am using iOS 6.0 beta and my spins no longer work.

Where can I set supported UINavigationControllersOrientations?

Accordingly, the http://news.yahoo.com/apple-ios-6-beta-3-changes-182849903.html UINavigation controller does not advise its children to determine if they should autorotate.

I do not use shouldAutorotateToInterfaceOrientation: anymore since it is deprecated. Instead, I use supportedInterfaceOrientations: and shouldAutoRotate: and they work fine until I put the ViewController in the NavigationController (as a child). From now on, the orientations specified in the ViewController no longer work. It seems to use the orientations set by the navigation controller (UIInterfaceOrientationMaskAllButUpsideDown)

How can I set InterfaceOrientations for a NavigationController so that my ViewControllers are locked in Portrait-Orientation?

Do I need to subclass UINavigationController and set InterfaceOrientations there? Isn't that a bad practice for a subclass of UINavigationController still in iOS 6.0?

Thank you for helping the heaps!

Hooray!

+5
2

, , UINavigationController

@implementation UINavigationController (Rotation_IOS6)

-(BOOL)shouldAutorotate
{
    return [[self.viewControllers lastObject] shouldAutorotate];
}

-(NSUInteger)supportedInterfaceOrientations
{
    return [[self.viewControllers lastObject] supportedInterfaceOrientations];
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return [[self.viewControllers lastObject] preferredInterfaceOrientationForPresentation];
}

@end
+9

UINavigationController

//OnlyPortraitNavigationController.h

@interface OnlyPortraitNavigationController : UINavigationController

//OnlyPortraitNavigationController.m

@implementation OnlyPortraitNavigationController

- (BOOL)shouldAutorotate {
    return NO;
}

-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return UIInterfaceOrientationPortrait; //for locked only Portrait
}

navigationController ViewController

SomeViewController *onlyPortraitVC = [[SomeViewController alloc]init];

OnlyPortraitNavigationController *portraitNav = [[OnlyPortraitNavigationController alloc]initWithRootViewController:onlyPortraitViewController];

[self presentViewController:portraitNav animated:YES completion:NULL];

, , .

+4

All Articles