问题描述
最近我一直在想,一个iOS应用程序只有一个 UIWindow
。
创建另一个 UIWindow
并将其放在屏幕上似乎并不是一个问题。
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
and place it on screen.
我的问题是有点模糊,但我有兴趣:
My question is kind of vague, but I'm interested in:
- 第二个
- 使用多个
UIWindow
实例时会出现什么问题? - 我看到人们使用第二个
UIWindow
在iPhone上显示视图等popover。这是一个很好的方法吗?为什么?为什么不呢? - 还有其他例子,让另一个
UIWindow
吗?
- What could I potentially achieve with a second
UIWindow
that cannot be done in other ways? - What can go wrong when using multiple
UIWindow
instances? - I have seen that people use a 2nd
UIWindow
to display popover like views on iPhone. Is this a good way of doing it? Why? Why not? - Are there other examples where it is making perfectly sense to have another
UIWindow
?
这不是我缺少的东西。我从来没有觉得需要创建另一个 UIWindow
实例,但也许这将允许做惊人的事情,我不知道! : - )
It's not that I'm missing something. I have never felt the need to create another UIWindow
instance but maybe it would allow doing amazing things I'm not aware of! :-)
我希望它可以帮助我解决这个问题:
我需要添加一个覆盖视图任何当前显示。如果已经存在一个或多个模态控制器,它也应当工作。如果我添加一个 UIView
到根控制器的视图,模态控制器位于顶部,所以popover控制器。
I'm hoping that it might help me solve this problem:I need to add a "cover view" over whatever is currently displayed. It should also work if there are already one or more modal controllers presented. If I add a UIView
to the root controller's view, the modal controllers sit on top, so do the popover controllers.If I present the cover view modally and there is already a modal controller, only part of the screen is covered.
推荐答案
如果我以模态方式呈现封面视图,并且已经有一个模态控制器,则只覆盖屏幕的一部分。 p> A UIWindow
可以浮在其他UI元素(如系统键盘)之上。
A UIWindow
can float above other UI elements like the system keyboard.
a UIWindow
与您的主窗口具有相同的框架。将其 windowLevel
属性设置为 UIWindowLevelStatusBar
。将其隐藏
属性设置为 NO
。
To address your last paragraph: Make a UIWindow
with the same frame as your main window. Set its windowLevel
property to UIWindowLevelStatusBar
. Set its hidden
property to NO
.
这篇关于优点,问题,添加另一个UIWindow到iOS应用程序的示例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!