1

I started by building 2 versions of my app, on for 3.5 inch screens and one for 4 inch with only the storyboard being different. I brought the 3.5 storyboard into the 4 inch project and used the following code in my appDelegate.m to have the program run the appropriate storyboard.

UIViewController *vc; if([[UIDevice currentDevice]userInterfaceIdiom]==UIUserInterfaceIdiomPhone) { if ([[UIScreen mainScreen] bounds].size.height == 568.0f) { NSLog(@"IPHONE IS WORKING"); UIStoryboard *storybord = [UIStoryboard storyboardWithName:@"Main.storyboard" bundle:nil]; vc = [storybord instantiateInitialViewController]; } else { UIStoryboard *storybord = [UIStoryboard storyboardWithName:@"MainFour.storyboard" bundle:nil]; vc = [storybord instantiateInitialViewController]; } } else { UIStoryboard *storybord = [UIStoryboard storyboardWithName:@"iPad" bundle:nil]; vc = [storybord instantiateInitialViewController]; } [_window setRootViewController:vc]; [_window makeKeyAndVisible]; 

When I use this, I get the error:

"Could not find a storyboard named 'Main.storyboard' in bundle NSBundle"

The error happens even if I try and use the storyboard that was not imported, the one that runs if the above code is missing. So I am assuming that the error lies in the name of the storyboard. In the project navigator, the storyboard is named "Main.storyboard" but calling that name does not find it. What am I doing wrong? Thanks.

2
  • If you look under Build Phases > Copy Bundle Resources is it there? Commented Apr 29, 2014 at 14:54
  • Yes, both of my storyboards are there. Commented Apr 29, 2014 at 15:00

1 Answer 1

5

Drop the .storyboard extension from the name you specify.

From the reference:

storyboardWithName:bundle: 

Creates and returns a storyboard object for the specified storyboard resource file.

+ (UIStoryboard *)storyboardWithName:(NSString *)name bundle:(NSBundle *)storyboardBundleOrNil 

Parameters

name The name of the storyboard resource file without the filename extension. This method raises an exception if this parameter is nil.

Sign up to request clarification or add additional context in comments.

1 Comment

That is so odd, this is one of the first solutions I tried and it did not work, but now it is working. Thanks for the help. I'll mark this as the answer.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.