Reanimation Reanimation - 1 year ago 73
iOS Question

Added iPad Storyboards, Now: "expected to have a root view controller..."

I've had an iPhone only app, built for the most part with the

Interface builder

I have a storyboard for each screensize/device.
In the
, it selects the correct storyboard and loads it.

I've since redesigned my app and now adding iPad compatibility.

I've added two new storyboards, fixed their size to "iPad Full Screen" and "iPad Pro Full Screen".

I've copied in the existing iPhone Storyboards and ticked the first board as "Is Initial View Controller".
I've also followed THIS POST and opened storyboards as source code and updated the target from default to iPad.

When I launch the app on an iPad, i just get a black screen with the following error:

Application windows are expected to have a root view controller at the end of application launch

Why is this happening?

This is the only thing I've changed in my
to select the correct Storyboard:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

UIViewController *initialViewController = nil;
CGSize result = [[UIScreen mainScreen] bounds].size;

if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone){

if(result.height == 480){
NSLog(@"iPhone 3.5 Inch");
UIStoryboard *i4SB = [UIStoryboard storyboardWithName:@"iPhone35" bundle:nil];
initialViewController = [i4SB instantiateInitialViewController];
if(result.height == 568){
NSLog(@"iPhone 4 Inch");
UIStoryboard *i5SB = [UIStoryboard storyboardWithName:@"iPhone4" bundle:nil];
initialViewController = [i5SB instantiateInitialViewController];
if(result.height == 667){
NSLog(@"iPhone 4.7 Inch");
UIStoryboard *i47SB = [UIStoryboard storyboardWithName:@"iPhone47" bundle:nil];
initialViewController = [i47SB instantiateInitialViewController];
if(result.height == 736){
NSLog(@"iPhone 5.5 Inch");
UIStoryboard *i55SB = [UIStoryboard storyboardWithName:@"iPhone55" bundle:nil];
initialViewController = [i55SB instantiateInitialViewController];

//added iPad compatibility
if(result.height == 1024){
NSLog(@"iPad Mini(2,3,4) or iPad Air(1,2) or iPad(3,4) or iPad Pro(9.7inch)");
UIStoryboard *iPadMiniSB = [UIStoryboard storyboardWithName:@"iPadFull" bundle:nil];
initialViewController = [iPadMiniSB instantiateInitialViewController];
if(result.height == 1366){
NSLog(@"iPad Pro(12.9 Inch)");
UIStoryboard *iPadProSB = [UIStoryboard storyboardWithName:@"iPadPro" bundle:nil];
initialViewController = [iPadProSB instantiateInitialViewController];

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.rootViewController = initialViewController;
[self.window makeKeyAndVisible];
return YES;


As Bharat Nakum mentioned below, you can remove the
UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone

Of course, you can also add an extra condition for iPad (which is what I did).

It now looks like this:

if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone){
//set iPhone device storyboards here
else if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad){
//set iPad device storyboards here

This is also confirmed as an answer here.

Answer Source

Please remove this condition.

if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)

It is true only when device is iPhone.

So, your iPad storyboards are not initializing.

Hope this helps!

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download