How can you support features of iOS6 in an app with a Minimal Deployment Target
set to iOS 5.0?
For example, if a user has iOS 5 he will see one UIActionSheet
, if the user has iOS 6 he will see a different UIActionSheet
for iOS 6? How do you do this?
I have Xcode 4.5 and want an app running on iOS 5.
The iPhone 4S, iPhone 4, iPhone 3GS, iPad 2, new iPad 3 and fourth-generation iPod touch are all eligible for an update to iOS 6. We've assembled a list of the tweaks and new features that the iOS 6 update will bring to the mobile Apple experience. RECOMMENDED VIDEOS FOR YOU...
Audio player loading… iOS 5 brought many sweeping changes to the iPhone and other iDevices. Twitter integration, alternate routes in the Maps app, tweaked iMessages and wireless syncing over WiFi, all things that iDevice users were clamoring for.
It doesn't matter if you were among the millions who pre-ordered the iPhone 5 or fifth-generation iPod touch. The iPhone 4S, iPhone 4, iPhone 3GS, iPad 2, new iPad 3 and fourth-generation iPod touch are all eligible for an update to iOS 6.
Goodbye Google Maps and hello Apple Maps, finally with turn-by-turn directions. Before iOS 6, Google Maps didn't provide those coveted turn-by-turn instructions, and iPhone users had to pony up for expensive third-party apps like TomTom if they wanted their iPhone to direct them around town.
You should always prefer detecting available methods/feature rather then iOS versions and then assuming a method is available.
See Apple documentation.
For example, in iOS 5 to display a modal view controller we would do something like this:
[self presentModalViewController:viewController animated:YES];
In iOS 6, the presentModalViewController:animated:
method of UIViewController
is Deprecated, you should use presentViewController:animated:completion:
in iOS 6, but how do you know when to use what?
You could detect iOS version and have an if statement dictate if you use the former or latter but, this is fragile, you'll make a mistake, maybe a newer OS in the future will have a new way to do this.
The correct way to handle this is:
if([self respondsToSelector:@selector(presentViewController:animated:completion:)])
[self presentViewController:viewController animated:YES completion:^{/* done */}];
else
[self presentModalViewController:viewController animated:YES];
You could even argue that you should be more strict and do something like:
if([self respondsToSelector:@selector(presentViewController:animated:completion:)])
[self presentViewController:viewController animated:YES completion:^{/* done */}];
else if([self respondsToSelector:@selector(presentViewController:animated:)])
[self presentModalViewController:viewController animated:YES];
else
NSLog(@"Oooops, what system is this !!! - should never see this !");
I'm unsure about your UIActionSheet
example, as far as I'm aware this is the same on iOS 5 and 6. Maybe you are thinking of UIActivityViewController
for sharing and you might like to fallback to a UIActionSheet
if you're on iOS 5, so you might to check a class is available, see here how to do so.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With