Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @implementation UINavigationController (MHAutorotation)
- - (BOOL)shouldAutorotate {
- return [self.topViewController shouldAutorotate];
- }
- - (UIInterfaceOrientationMask)supportedInterfaceOrientations {
- return [self.topViewController supportedInterfaceOrientations];
- }
- - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
- return [self.topViewController preferredInterfaceOrientationForPresentation];
- }
- - (UIViewController *)childViewControllerForStatusBarStyle {
- return self.topViewController;
- }
- - (UIViewController *)childViewControllerForStatusBarHidden {
- return self.topViewController;
- }
- @end
- @implementation UITabBarController (MHAutorotation)
- - (BOOL)shouldAutorotate {
- UIViewController *vc = self.viewControllers[self.selectedIndex];
- if ([vc isKindOfClass:[UINavigationController class]]) {
- UINavigationController *nav = (UINavigationController *)vc;
- return [nav.topViewController shouldAutorotate];
- }
- else {
- return [vc shouldAutorotate];
- }
- }
- - (UIInterfaceOrientationMask)supportedInterfaceOrientations {
- UIViewController *vc = self.viewControllers[self.selectedIndex];
- if ([vc isKindOfClass:[UINavigationController class]]) {
- UINavigationController *nav = (UINavigationController *)vc;
- return [nav.topViewController supportedInterfaceOrientations];
- }
- else {
- return [vc supportedInterfaceOrientations];
- }
- }
- - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
- UIViewController *vc = self.viewControllers[self.selectedIndex];
- if ([vc isKindOfClass:[UINavigationController class]]) {
- UINavigationController *nav = (UINavigationController *)vc;
- return [nav.topViewController preferredInterfaceOrientationForPresentation];
- }
- else {
- return [vc preferredInterfaceOrientationForPresentation];
- }
- }
- @end
- @implementation UISplitViewController (MHAutorotation)
- - (BOOL)shouldAutorotate
- {
- UIViewController *vc = self.viewControllers.lastObject;
- if ([vc isKindOfClass:[UINavigationController class]]) {
- UINavigationController *nav = (UINavigationController *)vc;
- return [nav.topViewController shouldAutorotate];
- }
- else {
- return [vc shouldAutorotate];
- }
- }
- - (UIInterfaceOrientationMask)supportedInterfaceOrientations
- {
- UIViewController *vc = self.viewControllers.lastObject;
- if ([vc isKindOfClass:[UINavigationController class]]) {
- UINavigationController *nav = (UINavigationController *)vc;
- return [nav.topViewController supportedInterfaceOrientations];
- }
- else {
- return [vc supportedInterfaceOrientations];
- }
- }
- - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
- {
- UIViewController *vc = self.viewControllers.lastObject;
- if ([vc isKindOfClass:[UINavigationController class]]) {
- UINavigationController *nav = (UINavigationController *)vc;
- return [nav.topViewController preferredInterfaceOrientationForPresentation];
- }
- else {
- return [vc preferredInterfaceOrientationForPresentation];
- }
- }
- - (UIViewController *)childViewControllerForStatusBarStyle
- {
- UIViewController *vc = self.viewControllers.lastObject;
- if ([vc isKindOfClass:[UINavigationController class]]) {
- UINavigationController *nav = (UINavigationController *)vc;
- return nav.topViewController;
- }
- else {
- return vc;
- }
- }
- - (UIViewController *)childViewControllerForStatusBarHidden
- {
- UIViewController *vc = self.viewControllers.lastObject;
- if ([vc isKindOfClass:[UINavigationController class]]) {
- UINavigationController *nav = (UINavigationController *)vc;
- return nav.topViewController;
- }
- else {
- return vc;
- }
- }
- @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement