No matter how hard I’ve tried to tweak my Storyboard, there are always areas that only look well on one particular version of iOS. There is no “one Storyboard fits all” approach.
The easiest option is to have one Storyboard for iOS 6 and another for iOS 7 – then everybody’s happy. Question is, how do we tell our app which one to load depending on the iOS version our device is running?
Here’s how: AppDelegate.m to the rescue! Let’s determine it in applicationDidFinishLaunchingWithOptions:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // load storyboard depending on iOS version UIStoryboard *storyboard; if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_6_1) { // Load resources for iOS 6.1 or earlier storyboard = [UIStoryboard storyboardWithName:@"OldStoryboard" bundle:nil]; } else { // Load resources for iOS 7 or later storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil]; } // show the storyboard self.window.rootViewController = [storyboard instantiateInitialViewController]; [self.window makeKeyAndVisible]; return YES; }
This will override whichever Storyboard is defined in the target (under Deployment Info, Main Interface).