Reputation: 419
I have been asked this question many times in the interview searched every where didn't get any proper answer.So finally posting this question here.
Upvotes: 24
Views: 10202
Reputation: 931
Generally one application require only 1 UIWindow, but still there may be some scenarios where you need to use multiple UIWindow in one application.
For example, you wish to show a view on the top of system AlertViews, or can the default Keyboard.
UIWindows are the special UIViews, for which their display order is controlled by .windowLevel property.
You don't need to add a new UIWindow as a subview of any of view. You can simply create a new UIWindow and call either window setHidden:NO or window makeKeyAndVisible depend on the level, you have given to it.
There are three default window enum levels defined:
UIWindowLevelNormal
UIWindowLevelStatusBar
UIWindowLevelAlert
Upvotes: 7
Reputation: 1385
You may go through this.
Yes, you can have multiple windows. A key window is the one that receives the user input.
Starting with Rob's answer I played around a bit and would like to write down some notes for others trying to get information on this topic:
UIWindow
. Just create one
and makeKeyAndVisible
. Done.UIWindow
covers everything, even modals, popovers, etc. Brilliant!UIWindow
is always in portrait implicitly. It does not rotate.UIWindow
can be used to bring views on the screen that float on top of everything. Without creating a dummy controller just to embed that in a UIPopoverController.Upvotes: 51
Reputation: 11770
Of course it can have multiple windows. Just, only one to be displayed at a time, that's the keyWindow
. You can have multiple windows stored in array or whatsoever, and make them keyWindow
when you want to display them.
And, yeah, read the documentation @Mannopson suggested, it's very useful.
Upvotes: -1