Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unexpected nil window in _UIApplicationHandleEventFromQueueEvent

One of my old apps is not working with iOS8. When I start the app up, and try to tap on the screen anywhere, I get this message in my console:

unexpected nil window in _UIApplicationHandleEventFromQueueEvent, 
_windowServerHitTestWindow: <UIWindow: 0x7fe4d3e52660; frame = (0 0; 320 568); 
opaque = NO; autoresize = RM+BM; gestureRecognizers = <NSArray: 0x7fe4d3e2c450>; 
layer = <UIWindowLayer: 0x7fe4d3e86a10>>

I'm using an old style MainWindow.xib. In the MainWindow.xib is my Window object, as well as a UINavigationController which has its first View Controller defined within as well. The image below is showing the Outlets connected to the App Delegate.

The white "view" in the screenshot below is the UIWindow. The view on the right is the UINavigationController (nav bar hidden) with the first ViewController defined inside it.

enter image description here

How do I fix this without recreating the entire app from scratch with a new project?

EDIT: I just discovered there is a TINY strip wherein my buttons will actually receive their taps/clicks.

I've also noticed that my self.view.window is nil. How do I make sure that is set?

enter image description here

like image 803
Kenny Wyland Avatar asked Sep 21 '14 19:09

Kenny Wyland


5 Answers

Additional to B H answer. Also look this answer.

Got this issue when launching my landscape only app from portrait orientation (also the app shouldn't be presented in recently opened apps list, which can be seen by pressing Home button twice. Perhaps, iOS somehow caches the orientation and window size).

My code was

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

I set W+H autoresizing mask for window, it didn't help me, because the window don't being resized on rotation, but the transform matrix is changed.

The solution is simple

self.window = [UIWindow new];
[self.window makeKeyAndVisible];
self.window.frame = [[UIScreen mainScreen] bounds];

So the frame is set AFTER the window get its orientation from root view controller.

like image 127
efpies Avatar answered Nov 17 '22 18:11

efpies


You don't have to add any code to fix this.

Open the main xib file and find "Window" from the left side and enable Visible at Launch and Full Screen at launch.

enter image description here

like image 25
frankish Avatar answered Nov 17 '22 18:11

frankish


Check out your Window nib file and make sure it is taking up the full screen. I had a similar issue on my app where touch events weren't being registered on a strip on the right side. Once I set my MainWindow.xib to take up the Full Screen, I had no more errors and touch events were working again. My app was also being displayed in Landscape but my MainWindow.xib had portrait dimensions.

like image 4
B H Avatar answered Nov 17 '22 17:11

B H


Sometimes it's just simple setting that's missing some value: Click on Project(whatever you named your project) name item then make sure General tab is selected and scroll to the bottom. Look for App icons and Launch Images make sure there is some value in the Launch Screen File field, this should be either Main or LaunchScreen

like image 4
don Avatar answered Nov 17 '22 16:11

don


In case somebody finds this useful:

In my case, I had used

self.window = [[UIWindow alloc] init];

instead of

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

and that was the reason for the problem.

like image 3
Totoro Avatar answered Nov 17 '22 16:11

Totoro