Created
February 11, 2014 06:50
-
-
Save dodyw/8930334 to your computer and use it in GitHub Desktop.
force portrait
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
- (void)forcePortrait | |
{ | |
if (UIDeviceOrientationIsLandscape([[UIDevice currentDevice] orientation])) | |
{ | |
if ([[UIDevice currentDevice] respondsToSelector:@selector(setOrientation:)]) | |
{ | |
int orientationPortrait = UIInterfaceOrientationPortrait; | |
NSMethodSignature *sig = [[UIDevice currentDevice] methodSignatureForSelector:@selector(setOrientation:)]; | |
NSInvocation* invo = [NSInvocation invocationWithMethodSignature:sig]; | |
[invo setTarget:[UIDevice currentDevice]]; | |
[invo setSelector:@selector(setOrientation:)]; | |
[invo setArgument:&orientationPortrait atIndex:2]; | |
[invo invoke]; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment