iosuiwindow

Is it possible that an iOS application can have more than one window?


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.


Solution

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

    1. It is not a problem at all to add another UIWindow. Just create one and makeKeyAndVisible. Done.
    2. Remove it by making another window visible, then release the one you don't need anymore.
    3. The window that is "key" receives all the keyboard input.
    4. UIWindow covers everything, even modals, popovers, etc. Brilliant!
    5. UIWindow is always in portrait implicitly. It does not rotate.
    6. You'll have to add a controller to the new window's root controller and let that handle rotation.
    7. (Just like the main window) The window's level determines how "high" it gets displayed. Set it to UIWindowLevelStatusBar to have it cover everything.
    8. Set its hidden property to NO. A 2nd 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.
    9. It can be especially useful for iPhone where there is no popover controller but where you might want to mimic something like it.
    10. And yes, it solved, of course, my problem: if the app resigns activation, add a cover window over whatever is currently shown to prevent iOS from taking a screenshot of your app's current content.