_UIApplicationHandleEventFromQueueEvent中的意外nil窗口 [英] unexpected nil window in _UIApplicationHandleEventFromQueueEvent

查看:143
本文介绍了_UIApplicationHandleEventFromQueueEvent中的意外nil窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的一个旧应用程序无法使用iOS8。当我启动应用程序,并尝试在任何地方点击屏幕时,我在我的控制台中收到此消息:

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>>

我使用旧式MainWindow.xib。在MainWindow.xib中是我的Window对象,以及UINavigationController,它也在其中定义了第一个View Controller。下图显示了连接到App Delegate的Outlets。

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.

下面屏幕截图中的白色视图是UIWindow。右边的视图是UINavigationController(导航栏隐藏),其中定义了第一个ViewController。

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.

如何在不使用新项目从头开始重新创建整个应用程序的情况下解决此问题?

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

编辑:我刚发现有一个TINY条带,其中我的按钮实际上会收到他们的点击/点击。

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

I我也注意到我的self.view.window是零。如何确保设置?

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

推荐答案

除了BH回答。另请参阅此答案

Additional to B H answer. Also look this answer.

从纵向启动我的横向应用程序时出现此问题(也不应该在最近打开的应用程序列表中显示该应用程序,可以通过按Home键两次看到。也许,iOS以某种方式缓存方向和窗口大小。)

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).

我的代码是

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

我设置 W + H 自动调整掩码窗口,它没有帮助我,因为窗口没有在旋转时调整大小,但转换矩阵已更改。

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.

解决方案很简单

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.

这篇关于_UIApplicationHandleEventFromQueueEvent中的意外nil窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆