Set different supportedInterfaceOrientations for different UIViewControllers
Asked Answered
S

2

2

So, as by the question, I use the following code to set userinterfaceOrientation for the viewcontroller.

- (BOOL) shouldAutorotate
{
    return YES;
}

-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskPortrait;
}

I tried setting UIInterfaceOrientationMaskAll for another viewController.

Prior, I checked all the items for Supported interface orientations in the info-plist. Both the viewControllers returned true(as set in the info-plist) for all the orientations and didn't obey the above code. IT worked even in the absence of the above code. Is there anyway to restrict certain Supported interface orientations for particular classes? I made it working for the pre - iOS6 versions by following this link.

Sanctity answered 26/9, 2012 at 11:38 Comment(0)
K
1

I was able to accomplish this by placing my supported orientation logic in a custom UINavigationController. I then segue to the relevant view controller.

@implementation PortraitNavigationController

- (NSUInteger)supportedInterfaceOrientations{
    return UIInterfaceOrientationMaskPortrait;
}

...

Kerns answered 26/9, 2012 at 12:56 Comment(1)
Thanks, I created a category and set different options as you did for different viewcontrollers. I referred the link https://mcmap.net/q/712668/-uitabbarcontroller-rotation-issues-in-ios-6Sanctity
T
-1

I'd say implement your shouldAutorotateToInterfaceOrientation: on every view controller to make it return only YES for those orientations you wish to support.

Tala answered 26/9, 2012 at 11:40 Comment(2)
thanks for your response. But shouldAutorotateToInterfaceOrientation is depreciated in iOS6, hence its not called. Thats the problem. I was using it in pre-iOS6 versionsSanctity
Sorry for my misplaced answer, I was not paying attention enough. For iOS 6, I hope someone else will chime in.Tala

© 2022 - 2024 — McMap. All rights reserved.