Created by Jamz Tang at 2 June 2012
In Xcode 4, you can simply point-and-click to specify supported orientation in your info.plist. But wait, it doesn't really make your app obey to that certain interface orientation.
You still have to implement the - [UIViewController
shouldAutorotateToInterfaceOrientation:]
and return a right value.
Your specified value is located in your app's info.plist, so here's the code to let you easily access that configuration.
Example usage
// In your ViewController.m subclass that you wish to just obey the specified supported orientations,
#import "UIApplicationAddition.h"
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return
UIInterfaceOrientationIsSupportedOrientation(interfaceOrientation);
}
Now you can just point-and-click to really change the supported orientations!
Clone this repository:
git clone git://gist.github.com/2853792.git UIApplicationAddition
If you think this is useful, share this article with your friends :)
blog comments powered by DisqusUINibDecoderProxy Observes what's encoded in an NSCoder object
JTKeyValueObserver Revisiting KVO+Block, the simplest version.
MethodSwizzle Method Swizzling in Objective-C
UITableViewDeleteActionResponder Quick hack to enable delete menu item in UITableView menuController
UIApplicationAddition Quickly switch supported UIInterfaceOrientation for your View Controllers
JTTargetActionBlock Adding Block support for UIControl's Target-Action mechanism
NSArray-JTArraySplit Splitting an array to several components
UIImage+JTImageDecode Force decompressing UIImage in background to achieve better performance
UINavigationBar-JTDropShadow Adding drop shadow on UINavigationBar (before iOS 6)
UIImage-JTImageCrop Crop an image in specific rect
UIView+JTRemoveAnimated Adding fadeout effect to any -[UIViews removeFromSuperview]
JTStringAddition NSStringf. Simpler printf styled +[NSString stringWithFormat:]
UIView-JTViewToImage Rendering any UIViews into UIImage in one line (updated with iOS 7 support)
NSObject-JTNibLoader Loading a Nib file programmatically using NSObject category
UIImage-JTColor Creating a placeholder UIImage dynamically with color
NSObject-JTCancelableScheduledBlock Cancelable Scheduled Blocks in Objective-C