Reputation: 1845
i have built my application using xcode 5 to support ios 6 or above.I want the same application to work on versions less than 6. I am not using auto layout.I changed all my nib files to build with os 4.3 or later.But the deprecated methods do not work on the older versions.what is the best possible way to support multiple ios versions(In my case ios 4.3 to ios 7.0)?.
Upvotes: 2
Views: 647
Reputation: 23301
Please avoid to make deployment target as 4.3. use this link currently no device using 4.3. its waste of time
you can do with only native code or xib if you want do app with deployment target as 4.3.
because auto layout doesn't support 4.3 and 5.0
stroyboard not support 4.3
Upvotes: 2
Reputation: 2395
http://www.raywenderlich.com/42591/supporting-multiple-ios-versions-and-devices can give you good advices.
short part of the article:
Unsupported classes
Sometimes you want to use a class that exists in
your base SDK, but not in your deployment target. To do this you need
to check the availability of this class at runtime to avoid crashing
your app. It crashes because this is what the Objetive-C
runtime will
do if you try to use a class that doesn’t exist. As of iOS 4.2,
classes are weakly linked so you can use the +class method to perform
the runtime check. For example:
if ([SLComposeViewController class]) {
//Safe to use SLComposeViewController } else {
//Fail gracefully }
Unsupported methods
Similarly, if you’re using a method in your base SDK that doesn’t exist in your deployment
target, you can avoid nasty crashes by using a little introspection.
The methods -respondsToSelector:
and +instancesRespondToSelector:
will
both do the trick, as shown in the code examples below:
if
([self.image respondsToSelector:@selector(resizableImageWithCapInsets:resizingMode:)])
{
//Safe to use this way of creating resizable images } else {
//Fail gracefully }
The same goes for verifying the existence of class methods, except you call respondsToSelector: on the class itself, like so:
if ([UIView
respondsToSelector:@selector(requiresConstraintBasedLayout)]) {
//Safe to use this method } else {
//Fail gracefully }
Upvotes: 3
Reputation: 7207
What I would like to suggest you, first block your code by version. I mean make block for deprecated methods like IOS 7, IOS 6 as on. Then try to find out the appropriate method that is supported by that version. But as far I knew you can't give full support to the version 4.3 like 7.
As @rckoenes say 80% is on iOS 7 the rest is on 6 and some are on 5. 4.3 is hardly used
so I am also not give support below 6.0. So best of luck.
Upvotes: 2