1
votes

EDIT: People downvoting this because I used sleep, this is why I used it:

Making the launch image display longer xcode

The window size is small. If you don't want to answer, don't downvote it. I just want to get rid of this error.

unexpected nil window in _UIApplicationHandleEventFromQueueEvent, _windowServerHitTestWindow: UIClassicWindow: ; frame = (0 0; 320 568); userInteractionEnabled = NO; gestureRecognizers = NSArray: > ; layer = UIWindowLayer: >>


I have an iOS app which runs on both iPad and iPhone in landscape mode. It runs fine on the ipad simulators but on the iphone 5s and iphone 6s (which I have tested so far), I get this error:

unexpected nil window in _UIApplicationHandleEventFromQueueEvent, _windowServerHitTestWindow: UIClassicWindow: ; frame = (0 0; 320 568); userInteractionEnabled = NO; gestureRecognizers = NSArray: > ; layer = UIWindowLayer: >>

This is the AppDelegate code.. I don't have any problem on ipad.

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

//   [NSThread sleepForTimeInterval:3];

    [application setStatusBarHidden:YES];
    self.window = [UIWindow new];       

    if([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad) {

        self->_loginViewController = [[LoginViewController alloc] initWithNibName:@"somename~ipad" bundle:nil];

    } else if([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone) {

        self->_loginViewController = [[LoginViewController alloc] initWithNibName:@"somename~iphone" bundle:nil];
    }

    [[NSUserDefaults standardUserDefaults] setValue:@(NO) forKey:@"_UIConstraintBasedLayoutLogUnsatisfiable"];

    self.window.rootViewController = nil;
    self.window.rootViewController = self->_loginViewController;

    [[UINavigationBar appearance] setBarTintColor:[UIColor blackColor]];
    [[UINavigationBar appearance] setTranslucent:NO];

    [self.window makeKeyAndVisible];
    [self.window setFrame:[[UIScreen mainScreen] bounds]];
    return YES;
}
1
NEVER sleep on the main thread.rmaddy
@rmaddy I have a launch image. I want it to display for 3 seconds, so I put that.Swift
@Anbu.Karthik I tried the solution in that post. Unfortunately, it didn't work for meSwift
Show the same image in your root controller. Set a timer to go off in 3 seconds. When the timer goes off, remove the image.rmaddy

1 Answers

0
votes

I figured out that I was getting the "unexpected nil window" error because I was using Asset catalog for my landscape application.

https://developer.apple.com/library/content/technotes/tn2244/_index.html#//apple_ref/doc/uid/DTS40009012

Avoid using asset catalogs to manage the launch images of landscape applications. Except for launch images used by the iPhone 6 Plus, asset catalogs assume that all iPhone launch images are for the portrait orientation.