Created
May 28, 2014 13:33
-
-
Save macguru/17ee7d47acbb4d4a2258 to your computer and use it in GitHub Desktop.
Enforce device rotation by using a temporary window and view controller.
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 FixedViewController : UIViewController | |
@property(nonatomic) NSUInteger supportedInterfaceOrientations; | |
@end | |
@implementation FixedViewController | |
@end | |
... | |
- (void)rotateToInterfaceOrientation:(UIInterfaceOrientation)orientation | |
{ | |
UIWindow *window = [[UIWindow alloc] initWithFrame: UIScreen.mainScreen.bounds]; | |
[window makeKeyAndVisible]; | |
FixedViewController *vc = [FixedViewController new]; | |
vc.supportedInterfaceOrientations = 1 << orientation; | |
window.rootViewController = vc; | |
window.hidden = YES; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment