Created
June 30, 2016 13:20
-
-
Save bocato/641098d927b64d102781959ac999d27e to your computer and use it in GitHub Desktop.
Hack to control screen orientation on iPad/iPhone for a specific inner ViewController
This file contains 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
- (UIInterfaceOrientationMask)supportedInterfaceOrientations | |
{ | |
if ([self.currentViewController isEqual:self.viewControllerYouDontWantToRotate]) | |
{ | |
return UIInterfaceOrientationMaskPortrait; | |
} | |
else | |
{ | |
return UIInterfaceOrientationMaskAll; | |
} | |
} | |
- (BOOL)shouldAutorotate | |
{ | |
if ([self.currentViewController isEqual:self.viewControllerYouDontWantToRotate]) | |
{ | |
return NO; | |
} | |
else | |
{ | |
return YES; | |
} | |
} | |
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation | |
{ | |
return UIInterfaceOrientationIsLandscape(toInterfaceOrientation); | |
} | |
- (void)rotateToLandscape{ | |
NSNumber *valueLandscape = [NSNumber numberWithInt:UIInterfaceOrientationLandscapeRight]; | |
[[UIDevice currentDevice] setValue:valueLandscape forKey:@"orientation"]; | |
} | |
- (void)rotateToPortrait{ | |
NSNumber *valuePortrait = [NSNumber numberWithInt:UIInterfaceOrientationPortrait]; | |
[[UIDevice currentDevice] setValue:valuePortrait forKey:@"orientation"]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment