Created
June 26, 2012 04:11
-
-
Save mmlac/2993236 to your computer and use it in GitHub Desktop.
UITabBarController with NavigationController that lets every view decide if it wants to be rotated
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@interface UITabBarController (MyApp) | |
@end | |
@interface UINavigationController (MyApp) | |
@end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@implementation UITabBarController (MyApp) | |
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation { | |
UIViewController *selectedVC = [self selectedViewController]; | |
if ([selectedVC respondsToSelector:@selector(shouldAutorotateToInterfaceOrientation:)]) { | |
return [selectedVC shouldAutorotateToInterfaceOrientation:toInterfaceOrientation]; | |
} | |
//optimistic return - if you want no rotation, you have to specifically tell me! | |
return YES; | |
} | |
@end | |
@implementation UINavigationController (MyApp) | |
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation { | |
UIViewController *visibleVC = [self visibleViewController]; | |
if ([visibleVC respondsToSelector:@selector(shouldAutorotateToInterfaceOrientation:)]) { | |
return [visibleVC shouldAutorotateToInterfaceOrientation:toInterfaceOrientation]; | |
} | |
//optimistic return - if you want no rotation, you have to specifically tell me! | |
return YES; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment