I already have the base code that supports ios 4.3 to ios 5. Now I would also like to support ios 6.0.
The present base code has modal views
, hard coded CGRect's
, and rotation is different for each view. So I would like to know whether we can support ios 4.3 to ios 6.0 with the same base code, by just tweaking some changes, or do we need to create a complete new target?
Like we cannot use auto layout of ios 6.0 if I want to support previous versions as it will lead to a crash.
Yes, we can do this by setting up the Deployment Target to iOS 4.3. But then, why do you need to support iOS < 5.0 as around 85-90% of devices are on iOS 5.0+. See this
Also, when you set up support for iOS 4.3 or even iOS 5.1.1, you would have to handle multiple things. For example, the method for Orientation,
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
isn't called for iOS 6. It is replaced by the methods,
- (NSUInteger)supportedInterfaceOrientations
- (BOOL)shouldAutorotate
You would need all the iOS versions on devices and then test each and every aspect of your app.
Using Xcode 4.5 it is perfectly valid to use one code base for building iOS 4.3 - 6.0 apps, but as always the key is testing on real iDevices with the given operating system versions.
Yes it is perfectly fine and can be done to support ios 4.3 to ios 6.0 using the xcode 4.5.
And for the orientations in ios 6 have to do some work around like have to put some code differently as posted in @Mayur J's answer.
Or all you can do is just add categories for the required controller's like UINavigationController
, UIPopoverViewController
, UIImagePickerViewController
, etc to return the supported orientation in ios 6.0 like below
.h file
#import <UIKit/UIKit.h>
@interface UIPopoverController (UIPopoverController_Orientation)
-(NSUInteger) supportedInterfaceOrientations;
@end
.m file
#import "UIPopoverController+UIPopoverController_Orientation.h"
@implementation UIPopoverController (UIPopoverController_Orientation)
-(NSUInteger) supportedInterfaceOrientations {
return UIInterfaceOrientationMaskLandscape;
}
@end
Here I use UIInterfaceOrientationMaskLandscape
as I only supports landscape orientations ie restrict my app to only landscape mode.
Hope this will help you.
Happy Coding :)