Skip to content

Instantly share code, notes, and snippets.

@zxx
Created June 3, 2015 15:02
Show Gist options
  • Save zxx/d5ba9caf800bd91d6751 to your computer and use it in GitHub Desktop.
Save zxx/d5ba9caf800bd91d6751 to your computer and use it in GitHub Desktop.
ios force screen orientation
// 强制横屏
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