Created
October 20, 2011 19:35
-
-
Save sorted-bits/1302088 to your computer and use it in GitHub Desktop.
shouldAllowRotateToInterfaceOrientation
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
+ (BOOL) shouldAllowRotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation | |
{ | |
NSString* currentOrientation = @""; | |
switch (interfaceOrientation) | |
{ | |
case UIInterfaceOrientationLandscapeLeft: | |
currentOrientation = @"UIInterfaceOrientationLandscapeLeft"; | |
break; | |
case UIInterfaceOrientationLandscapeRight: | |
currentOrientation = @"UIInterfaceOrientationLandscapeRight"; | |
break; | |
case UIInterfaceOrientationPortrait: | |
currentOrientation = @"UIInterfaceOrientationPortrait"; | |
break; | |
case UIInterfaceOrientationPortraitUpsideDown: | |
currentOrientation = @"UIInterfaceOrientationPortraitUpsideDown"; | |
break; | |
} | |
NSString* supportedOrientationsKey = @"UISupportedInterfaceOrientations"; | |
if([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad) | |
supportedOrientationsKey = @"UISupportedInterfaceOrientations~ipad"; | |
NSArray* allowedOrientations = [[[NSBundle mainBundle] infoDictionary] objectForKey:supportedOrientationsKey]; | |
for (NSString* allowedOrientation in allowedOrientations) | |
{ | |
if ([allowedOrientation isEqualToString:currentOrientation]) | |
return YES; | |
} | |
return NO; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment