Created
June 3, 2015 15:02
-
-
Save zxx/d5ba9caf800bd91d6751 to your computer and use it in GitHub Desktop.
ios force screen orientation
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
// 强制横屏 | |
if ([[UIDevice currentDevice] respondsToSelector:@selector(setOrientation:)]) { | |
SEL selector = NSSelectorFromString(@"setOrientation:"); | |
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[UIDevice instanceMethodSignatureForSelector:selector]]; | |
[invocation setSelector:selector]; | |
[invocation setTarget:[UIDevice currentDevice]]; | |
int val = UIInterfaceOrientationPortrait; | |
[invocation setArgument:&val atIndex:2]; | |
[invocation invoke]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment