I have been trying to do this for 2 weeks, and just found out the reason it's not working:
Deprecated APIs
The following APIs are deprecated:
The UIViewController methods and properties for interface orientation. Traits and size classes replace them, as described in Unified Storyboards for Universal Apps.
From what's new in iOS 8
What I need is: a FirstViewController
, which is the rootViewController
to my navigationController
. The FristViewController
should be only available in Portrait mode (not ever ever ever displayed in Landscape).
Then there are a few intermediate ViewControllers in the navigation stack (which support both orientations), until I reach a LastViewController
, which should be available only in LandscapeRight mode (and never ever ever in portrait, or another mode).
I have been trying with the following CustomNavigationController
, but apparently things changed in iOS8, and I can't get it to work:
- (BOOL)shouldAutorotate { // Available in iOS 6.0 and later
return YES; // // May use topViewController's, but in this app it always returns YES
}
- (NSUInteger)supportedInterfaceOrientations { // Available in iOS 6.0 and later
if (self.topViewController != nil)
return [self.topViewController supportedInterfaceOrientations];
else
return [super supportedInterfaceOrientations];
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { // Available in iOS 6.0 and later
if (self.topViewController != nil)
return [self.topViewController preferredInterfaceOrientationForPresentation];
else
return [super preferredInterfaceOrientationForPresentation];
}
Thanks!