I was trying to figure out the best way to implement support in my application for iOS5 where I can't use Auto Layout, and in iOS6 where I can. Thanks to Apple Developer forum to get this answered.
From what I gather, it looks like I will need to have two storyboards in my project, one for iOS6 with Auto Layout turned on, and one for iOS5 where it is turned off. If this isn't the best approach, I'd be interested in hearing suggestions.
That said, if I proceed as above, I'm not understanding how at run time I tell the app (in code I'm guessing) which storyboard to use based on whether the app is running on a device with iOS6 or iOS5.
In the Application Summary tab, I set my "Main Storyboard" to my iOS 5-based storyboard. Then using code (below), I detect if I'm on a device with iOS 6, and if so, I change to my iOS 6-based storyboard. To select the correct storyboard on application launch, I added the following to my AppDelegate.m:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
NSString *reqSysVer = @"6.0";
NSString *currSysVer = [[UIDevice currentDevice] systemVersion];
UIStoryboard *storyBoard;
if ([currSysVer compare:reqSysVer options:NSNumericSearch] != NSOrderedAscending)
{
storyBoard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
UIViewController *initViewController = [storyBoard instantiateInitialViewController];
[self.window setRootViewController:initViewController];
}
return YES;
}
Works like a charm!