Reputation: 3
I need to create 2 storyboards for my iOS 7 app in Xcode 5. I need a story board for the 4 inch screen and one for the 3.5 inch, because auto layout does not work with this app. I have one titled "iPhone_3.5" and one titled "Main". I put the following code in my AppDelegate.m:
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone){
UIStoryboard *storyBoard;
CGSize result = [[UIScreen mainScreen] bounds].size;
CGFloat scale = [UIScreen mainScreen].scale;
result = CGSizeMake(result.width * scale, result.height * scale);
if(result.height == 960){
storyBoard = [UIStoryboard storyboardWithName:@"iPhone_3.5.storyboard" bundle:nil];
UIViewController *initViewController = [storyBoard instantiateInitialViewController];
[self.window setRootViewController:initViewController];
}
}
But when I launch the app on my iPhone 4, it still shows the iPhone 5 storyboard, and thus looks terrible. Is there something that I'm missing here? Thanks!
Upvotes: 0
Views: 2320
Reputation: 1735
I am switching storyboards using storyBoardWithName:bundle same as yours but I didn't include the extension '.storyboard' to the string argument. Maybe you could try that up. Xcode may have trouble finding the storyboard file as a result it loads the default one which the Main.storyboard. Another thing is your equalities. Maybe you could use this instead.
if([UIScreen mainScreen].bounds.size.height>=568) {
// load iPhone 4 inch storyboard.
} else {
// load iPhone 3.5 inch storyboard
}
Upvotes: 2