UINavigationController处理屏幕旋转A simple UINavigationController subclass to handle iOS 6’s orientation changes better
#import <UIKit/UIKit.h>
@interface CJProperRotationNavigationController : UINavigationController
@end
#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