login view controller embedded in navigation controller must be only portrait. other view controller's pushed can rotate. scenario: if after signing in i rotate child view controller and then logout login view controller appears in landscape.
logincontroller(portrait)->rotated device->childcontroller(landscape)->back->logincontroller(landscape)
I want login controller to be portrait when I come back.
type these two methods in your login ViewController
(BOOL)shouldAutorotate { return YES;
}
(NSUInteger)supportedInterfaceOrientations {
return (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown); }
and
(BOOL)shouldAutorotate { return YES;
}
(NSUInteger)supportedInterfaceOrientations {
return (UIInterfaceOrientationLandscapeRight | UIInterfaceOrientationLandscapeLeft); }
in your childcontroller
required to add category autorotation subclassed navigation controller which would call topcontroller shouldautorotate and supported interface orientation.
#import "UINavigationController+Autorotation.h"
@implementation UINavigationController (Autorotation)
-(BOOL)shouldAutorotate
{
for (UIViewController * viewController in self.viewControllers) {
if (![viewController isEqual:self.topViewController]) {
[viewController shouldAutorotate];
}
}
return [self.topViewController shouldAutorotate];
}
-(NSUInteger)supportedInterfaceOrientations
{
for (UIViewController * viewController in self.viewControllers) {
if (![viewController isEqual:self.topViewController]) {
[viewController supportedInterfaceOrientations];
}
}
return [self.topViewController supportedInterfaceOrientations];
}