Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

unexpected nil window in _UIApplicationHandleEventFromQueueEvent, _windowServerHitTestWindow

I am trying to set up an edge swipe gesture in iOS 8 on iPad but getting and error that seems like a bug.

I have the following code:

    UIScreenEdgePanGestureRecognizer *edgeRecognizer = [[UIScreenEdgePanGestureRecognizer alloc] initWithTarget:self action:@selector(handleRightEdgeSwipe:)];
edgeRecognizer.edges = UIRectEdgeRight;
[self.view addGestureRecognizer:edgeRecognizer];

and then I handle the gesture:

-(void)handleRightEdgeSwipe:(UIGestureRecognizer*)sender
{
//slide in view code here
}

The problem is that it doesn't detect the right edge swipe every time. And sometimes it detects it multiple times.

Whether it detects or not it always shows the following information in the console when swiping the right edge on iPad:

2014-10-07 00:04:40.386 Office Log[1531:500896] unexpected nil window in _UIApplicationHandleEventFromQueueEvent, _windowServerHitTestWindow: ; layer = >

What does this message mean and how can I fix it so that the right edge swipe is detected consistently?

like image 469
motionpotion Avatar asked Oct 06 '14 23:10

motionpotion


2 Answers

I think it's a bug in iOS, which I can confirm on an iPad mini 2 and an iPad Air on iOS 7 or higher, even on the Home Screen.

In "Landscape Left" (Home button on the left) a "Right Edge Gesture" from outside the Screen is not working for me. Test it by your self on the Home Screen.

I reported a bug to Apple 9 Month ago, but noting further happened.

Update:

I played a bit with the UIWindow init and when it is a bit bigger than it really is, the Gesture works. Of course this is a horrible fix.

self.window = [UIWindow new];
self.window.rootViewController = [[UIViewController alloc] init];

// Real Size
CGRect frame = [UIScreen mainScreen].bounds;

// Real Size + 0.000001
self.window.frame = CGRectMake(0, 0, frame.size.width+0.000001, frame.size.height+0.000001);
[self.window makeKeyAndVisible];
like image 101
firebug Avatar answered Sep 20 '22 21:09

firebug


I got the same issue. My solution works fine: just set in your xib your Windows to hidden.

I don't really understand why it works, but it works.

EDIT 1:

I found another solution, better I think, and more understandable:

Put this code on your willFinishLaunchingWithOptions, in your appDelegate:

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

    CGRect bounds = [[UIScreen mainScreen] bounds];
    [self.window setFrame:bounds];
    [self.window setBounds:bounds];

    return YES;
}

Then, on your didFinishLaunchingWithOptions:

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

    // Your codes...

    self.window.rootViewController = self.navigationController;
    [self.window makeKeyAndVisible];

    return YES;
}

Your can then set your window object hidden to NO, and it should works.

like image 24
Lapinou Avatar answered Sep 21 '22 21:09

Lapinou