How to upload multiple storyboard files depending on iOS version? (5 and 6)

I have a tab bar controller application that I am trying to make compatible for iOS 6 and iOS 5. For iOS 6, I use a machine. But when I try to run on iOS 5, I get an error message due to which NSLayoutConstraints is not recognized.

From what I can say, I need to use a different storyboard without auto layout turned on. I copied my storyboard to a new one, but I don’t know how to set which layout to use in the application delegate.

What is the code for this?

+6
source share
1 answer

In your application you should find the following code:

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MyStoryboard" bundle:nil]; self.window.rootViewController = [storyboard instantiateInitialViewController]; [self.window makeKeyAndVisible]; 

Here you can add some code to choose among several storyboards that you have depending on the version of iOS :

 UIStoryboard *storyboard; NSString *currSysVer = [[UIDevice currentDevice] systemVersion]; if (...) { storyboard = [UIStoryboard storyboardWithName:@"MyStoryboard-v5" bundle:nil]; } else { storyboard = [UIStoryboard storyboardWithName:@"MyStoryboard-v6" bundle:nil]; } self.window.rootViewController = [storyboard instantiateInitialViewController]; [self.window makeKeyAndVisible]; 
+10
source

All Articles