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

    {
        CGSize iosScreenSize = [[UIScreen mainScreen] bounds].size;

        if (iosScreenSize.height == 667) {

            UIStoryboard *iPhone6 = [UIStoryboard storyboardWithName:@"iPhone6" bundle:nil];

            UIViewController *initialViewController =[iPhone6 instantiateInitialViewController];

            self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen]bounds]];

            self.window.rootViewController = initialViewController;

            [self.window makeKeyAndVisible];

        }

        return YES;
    }

    return YES;
}

That is all i added in AppDelegate.m. Im using Xcode 6.1. I did this because i'm not using auto layout so I created a separate ViewController and called it iPhone6.h and iPhone6.m and a created a storyboard for it calling it iPhone6. I've connected the iPhone6 storyboard to iPhone 6.h and .m so i don't understand why when i'm loading the iPhone6 simulator I automatically get the "Application windows are expected to have a root view controller at the end of application launch" error. Why am I getting it?

Matthias Bauch
  • 89,811
  • 20
  • 225
  • 247
Alex
  • 93
  • 1
  • 7
  • http://stackoverflow.com/a/7730798/653513 – Rok Jarc Dec 04 '14 at 23:08
  • Use the debugger or NSLog to see the value of `initialViewController` that you're assigning as root. – Phillip Mills Dec 04 '14 at 23:54
  • 1
    You are probably missing the iPhone 6 launch images, so your app is still launched in compatibility mode, which has a height of 568 points. Which means the code never enters the if block. Use the debugger to step through your code and to inspect `iosScreenSize`. --- _Obligatory Autolayout Propaganda_: for the sake of your own sanity, learn how to use auto layout. It's overly complicated and error prone to manage four different storyboards. Over the lifetime of your app you will probably spend more time debugging inconsistencies between those four than you would need to learn auto layout. – Matthias Bauch Dec 05 '14 at 00:34
  • @MatthiasBauch Brilliant analysis. Really should be an answer! – matt Dec 05 '14 at 00:59
  • I had all the launch images for all the proper sizes. It wasn't that. I fixed the error anyways. I know how to use Auto Layout but for some weird reason my entire app would become buggy with Auto Layout on so i turned it off. When it was off, everything was fine. It's my first app. For the second one i'll be using Auto Layout when i start from scratch. – Alex Dec 05 '14 at 02:52

1 Answers1

0

First of all check for value of initialViewController. if it getting null value then you are not selected any controller as initialView controller.

For select controller as initialViewController you have to go to story board and then select controller which you want to load initially and select option which is shown in image below.

enter image description here

Anbu.Karthik
  • 82,064
  • 23
  • 174
  • 143
Abhishek Sharma
  • 3,283
  • 1
  • 13
  • 22