1

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.

zachjs
  • 1,738
  • 1
  • 11
  • 22
footyapps27
  • 3,982
  • 2
  • 25
  • 42
  • 1
    You might want to look at [this question](http://stackoverflow.com/questions/12527517/what-is-the-best-way-for-supporting-both-screen-resolution-of-iphone4-and-iphone) – Janak Nirmal Oct 08 '12 at 07:17

3 Answers3

4

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.

mayuur
  • 4,736
  • 4
  • 30
  • 65
  • yeah, so is it a good idea to tweak the present target and make it compatible with all the versions? or create a new target altogether for ios 6.0? – footyapps27 Oct 08 '12 at 07:25
  • 1
    You should consider making a single app compatible with all the versions of iOS. At the end of the day, you are not gonna upload a separate app for each iOS Version. Also, every app uploaded after iOS 6 release, needs support for iOS 6, so iOS 6 compatibility is compulsory. – mayuur Oct 08 '12 at 07:30
  • hey, adding to that, so the method `- (NSUInteger)supportedInterfaceOrientations & - (BOOL)shouldAutorotate` will work fine in ios 4.3? – footyapps27 Oct 08 '12 at 07:31
  • yes they won't be called in versions < iOS 6. so you would have to write both. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation for versions < iOS 6 and - (NSUInteger)supportedInterfaceOrientations - (BOOL)shouldAutorotate for iOS 6 – mayuur Oct 08 '12 at 07:57
  • It's the other way around: supportedInterfaceOrientations is for iOS6, the other two are for pre-iOS6. – Clafou Feb 11 '13 at 15:59
1

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.

  • exactly, so I am testing the app in simulator 5.0 it works fine, but for simulator 6.0 I am getting so many bugs. What is the best way to deal with that? – footyapps27 Oct 08 '12 at 07:17
  • 1
    How do you deal with bugs in the rest of your development cycles? You find the location where you hit a brick wall and find a way through it, step by step. And you'll probably see that a fix to one bug clears out a lot others that relate to the same issue. But again, there is nothing like testing on real iPhones and iPads and iPod Touches, I found out the hard way... – Richard Altenburg - Brainchild Oct 08 '12 at 07:22
1

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 :)

The iOSDev
  • 5,237
  • 7
  • 41
  • 78
  • so this method will work fine for iOS 4.3 as well? Coz we had `-(BOOL)shouldAutorotateToInterfaceOrientation(UIInterfaceOrientation)interfaceOrientation` earlier. So if i put the above method, it will take care of both iOS 6 to iOS 4.3 – footyapps27 Oct 08 '12 at 07:40
  • yes works well as my app is also works fine on ios 4.3 for ipad – The iOSDev Oct 08 '12 at 08:24