iOS9.1 中的 UIWindow 删除错误

UIWindow remove error in iOS9.1

在iOS9.1中,当我通过removeFromSuperView移除自定义UIWindow并设置为nil时,它不会自动消失,直到点击window。并用

显示错误

unexpected nil window in _UIApplicationHandleEventFromQueueEvent, _windowServerHitTestWindow: (null)

在 iOS9 及以下时,它会正常工作。

UIWindow *window = [target associatedValueForKey:lock_window];
if (window) [window removeFromSuperview];
[target associateValue:nil withKey:lock_window];

我已经用代码解决了问题

UIWindow *window = [target associatedValueForKey:lock_window];
if (window) [window removeFromSuperview];
window.hidden = YES;
[target associateValue:nil withKey:lock_window];

- (void)makeKeyAndVisible 方法注释是

convenience. most apps call this to show the main window and also make it key. otherwise use view hidden property