Advantages, problems, examples of adding another UIWindow to an iOS app?

前端 未结 3 887
無奈伤痛
無奈伤痛 2020-11-27 10:04

Recently I\'ve been wondering about the fact that that an iOS app only has one UIWindow. It does not seem to be an issue to create another UIWindow

3条回答
  •  悲哀的现实
    2020-11-27 10:27

    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:

    • It is not a problem at all to add another UIWindow. Just create one and makeKeyAndVisible. Done.
    • Remove it by making another window visible, then release the one you don't need anymore.
    • The window that is "key" receives all the keyboard input.
    • UIWindow covers everything, even modals, popovers, etc. Brilliant!
    • UIWindow is always portrait implicitly. It does no rotate. You'll have to add a controller as the new window's root controller and let that handle rotation. (Just like the main window)
    • The window's level determines how "high" it gets displayed. Set it to UIWindowLevelStatusBar to have it cover everything. 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.
    • It can be especially useful on iPhone where there is no popover controller but where you might want to mimic something like it.
    • 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.

提交回复
热议问题