Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove a UIWindow?

I thought it was easy as [myWindow resignKeyWindow] and [self.window makeKeyAndVisible] but I guess not… Would you guys know what to do?

Thanks :)

like image 356
G33kz0r Avatar asked Dec 28 '10 07:12

G33kz0r


People also ask

What is UIWindow in iOS?

The backdrop for your app's user interface and the object that dispatches events to your views. iOS 2.0+ iPadOS 2.0+ Mac Catalyst 13.1+ tvOS 9.0+

What is the purpose of UIWindow object?

The presentation of one or more views on a screen is coordinated by UIWindow object. In iOS application usually only has one window. while View multiple. Windows and Views both are used for present your application's content on the screen.

Is UIWindow a UIView?

It's not an either/or kind of thing. Your app must have a UIWindow instance that is the container for the UIView instances you present. An app can either load the UIWindow instance from a nib file, or it can create it programmatically.


2 Answers

The correct way to hide a window is to set the hidden property to YES. To remove it from UIApplication's windows property you just release the window (in ARC you set all references to nil).

Of course you would want to have another window in place at this time.

like image 105
Nikolai Ruhe Avatar answered Oct 01 '22 03:10

Nikolai Ruhe


Do not invoke -resignKeyWindow directly, it was meant to be overridden to execute some code when your UIWindows gets removed. In order to remove old window you need to create new instance of UIWindow and make it -makeKeyAndVisible, the old window will resign its key status. In iOS 4 it will even garbage collect your old UIWindow, provided you don't have any references to it. Doing this in iOS 3.x would have disastrous effects. Warned ya.

like image 33
bioffe Avatar answered Oct 01 '22 03:10

bioffe