Skip navigation

Tag Archives: root

There is a really shitty post on stackoverflow about this, filled with nonsense.

I’m working with old OpenGL code. Specifically, code based off GLES2Sample.

There was a slight change around iOS 5.0 or so, requiring you to have a root view controller. If your code is based off older sample code, such as GLES2Sample, then no root view controller was created in those code samples.

To fix GLES2Sample, I know the following fix works. Right in `applicationDidFinishLaunching`, I create a root view controller and attach my glView to it.

    - (void) applicationDidFinishLaunching:(UIApplication *)application
    {
      // To make the 'Application windows are expected
      // to have a root view controller
      // at the end of application launch' warning go away,
      // you should have a rootviewcontroller,
      // but this app doesn't have one at all.
      window.rootViewController = [[UIViewController alloc] init];  // MAKE ONE
      window.rootViewController.view = glView; // MUST SET THIS UP OTHERWISE
      // THE ROOTVIEWCONTROLLER SEEMS TO INTERCEPT TOUCH EVENTS
    }

That makes the warning go away, and doesn’t really affect your app otherwise.