Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 20 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save lessthanyouthink/3842178 to your computer and use it in GitHub Desktop.
Save lessthanyouthink/3842178 to your computer and use it in GitHub Desktop.
A simple UINavigationController subclass to handle iOS 6's orientation changes better.
//
// CJProperRotationNavigationController.h
//
// Created by Charles Joseph on 2012-10-01.
//
#import <UIKit/UIKit.h>
@interface CJProperRotationNavigationController : UINavigationController
@end
//
// CJProperRotationNavigationController.m
//
// Created by Charles Joseph on 2012-10-01.
//
#import "CJProperRotationNavigationController.h"
@implementation CJProperRotationNavigationController
- (BOOL)shouldAutorotate {
if (self.topViewController != nil)
return [self.topViewController shouldAutorotate];
else
return [super shouldAutorotate];
}
- (NSUInteger)supportedInterfaceOrientations {
if (self.topViewController != nil)
return [self.topViewController supportedInterfaceOrientations];
else
return [super supportedInterfaceOrientations];
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
if (self.topViewController != nil)
return [self.topViewController preferredInterfaceOrientationForPresentation];
else
return [super preferredInterfaceOrientationForPresentation];
}
@end
@masabusharif
Copy link

Any Idea how to make this work if i have a UITabBarController?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment