将另一个 UIWindow 添加到 iOS 应用程序的优点、问题、示例? [英] Advantages, problems, examples of adding another UIWindow to an iOS app?

查看:15
本文介绍了将另一个 UIWindow 添加到 iOS 应用程序的优点、问题、示例?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近我一直想知道一个 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 实例时会出现什么问题?
  • 我已经看到人们使用第二个 UIWindow 在 iPhone 上像视图一样显示弹出窗口.这是一个很好的方法吗?为什么?为什么不呢?
  • 是否还有其他例子表明拥有另一个 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 添加到根控制器的视图中,模态控制器位于顶部,弹出控制器也是如此.如果我以模态方式呈现封面视图并且已经有一个模态控制器,则只会覆盖屏幕的一部分.

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.

推荐答案

UIWindow 可以浮动在其他 UI 元素(如系统键盘)之上.

A UIWindow can float above other UI elements like the system keyboard.

解决您的最后一段:制作一个与主窗口具有相同框架的 UIWindow.将其 windowLevel 属性设置为 UIWindowLevelStatusBar.将其 hidden 属性设置为 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 应用程序的优点、问题、示例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆