Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIWindow remove error in iOS9.1

In iOS9.1, When I remove a custom UIWindow by removeFromSuperView and set to nil, it did't disappear automatically until click on the window. and show error with

unexpected nil window in _UIApplicationHandleEventFromQueueEvent, _windowServerHitTestWindow: (null)

When in iOS9 and lower,it will works fine.

UIWindow *window = [target associatedValueForKey:lock_window];
if (window) [window removeFromSuperview];
[target associateValue:nil withKey:lock_window];
like image 370
Jane Avatar asked Dec 29 '25 20:12

Jane


1 Answers

I has solved the problem with code

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

the - (void)makeKeyAndVisible method annotation is

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

like image 199
Jane Avatar answered Jan 01 '26 10:01

Jane



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!