1

I'm playing around with a single-window template. I have a classic MainStoryboard.storyboard file and I have only 1 view controller (which is an Initial View Controller all by default)

What I do is I try to implement the behaviour from this example and the Xcode tells me this:

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

I don't understand what I'm doing wrong. Here's the piece of code where I create a new UIWindow:

UIWindow *overlayWindow = [[UIWindow alloc] init];
    overlayWindow = [[ACStatusBarOverlayWindow alloc] initWithFrame:CGRectZero];
    overlayWindow.hidden = NO;

And of course my appDelegate starts with this:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Override point for customization after application launch.
    return YES;
}

What am I doing wrong?

Community
  • 1
  • 1
Sergey Grischyov
  • 11,995
  • 20
  • 81
  • 120

1 Answers1

2

You should make your window key and visible by

[overlayWindow makeKeyAndVisible];

as suggested in the very same example you linked.

EDIT

This the code you are using

UIWindow *overlayWindow = [[UIWindow alloc] init];
overlayWindow = [[ACStatusBarOverlayWindow alloc] initWithFrame:CGRectZero];
overlayWindow.hidden = NO;

The first line its useless and potentially it is the one which is causing the warning. You are creating a UIWindow instance and than throwing it away in the next line.

Remove it and just do:

UIWindow *overlayWindow = [[ACStatusBarOverlayWindow alloc] initWithFrame:CGRectZero];
overlayWindow.hidden = NO;

Also you should assign a root view controller to the newly created window, by

overlayWindow.rootViewController = self.window.rootViewController;
Gabriele Petronella
  • 106,943
  • 21
  • 217
  • 235