Application windows are expected to have a root view control


#1

Hi everybody,

Currently when launching the app to test it the simulator attempts to load before turning white and then returning to the iOS home screen. When checking the console I’m getting “Application windows are expected to have a root view control” as an error.

For reference, here is what my code in BNRAppDelegate.m attempting to set my view controller to root looks like

[code]
@implementation BNRAppDelegate

  • (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
    BNRQuizViewController *quizVC = [[BNRQuizViewController alloc] init];
    self.window.rootViewController = quizVC;

    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];
    return YES;
    }[/code]

kind of lost, thanks in advanced for the help.


#2

I’m having the same problem (Xcode 5.1.1). I don’t know the solution, but a workaround is to create the app as a “Single View Application” rather than “Empty Application”.


#3

I think the problem is that your code is in the wrong location. The 2 lines you added that instantiate quizVC and assign it to the window root controller needs to be a few lines further down, after the comment line ‘// Override point for customization…’. Essentially, I believe, you’re trying to assign the root view controller before the window is instantiated. (Which is the line immediately prior to the comment line.)

Hope that helps.