Last active
October 5, 2015 18:29
-
-
Save jamztang/2853792 to your computer and use it in GitHub Desktop.
Handy marco to return supported UIInterfaceOrientation for your View Controllers
This file contains hidden or 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
// Created by Jamz Tang 2012-06-02 | |
// http://ioscodesnippet.com/post/24203288551/quickly-switch-supported-uiinterfaceorientation-for | |
// Convert UIInterfaceOrientation to NSString, so we can compare it | |
static inline NSString *NSStringFromUIInterfaceOrientation(UIInterfaceOrientation orientation) { | |
switch (orientation) { | |
case UIInterfaceOrientationPortrait: return @"UIInterfaceOrientationPortrait"; | |
case UIInterfaceOrientationPortraitUpsideDown: return @"UIInterfaceOrientationPortraitUpsideDown"; | |
case UIInterfaceOrientationLandscapeLeft: return @"UIInterfaceOrientationLandscapeLeft"; | |
case UIInterfaceOrientationLandscapeRight: return @"UIInterfaceOrientationLandscapeRight"; | |
} | |
return @"Unexpected"; | |
} | |
// Check info.plist for the UISupportedInterfaceOrientations key, it returns an array of NSString | |
#define UIInterfaceOrientationIsSupportedOrientation(orientation) ([[[NSBundle mainBundle] objectForInfoDictionaryKey:@"UISupportedInterfaceOrientations"] indexOfObject:NSStringFromUIInterfaceOrientation(orientation)] != NSNotFound) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice, thank you!