具有警报级别的 UIWindow 位于状态栏级别之上

UIWindow with Alert level is on top of Status Bar level

我有一个以模态方式呈现视图控制器的应用程序,我在不同的 UIWindow 中有一个标准 ViewController 和一个 UIAlertController,主要具有普通 UIWindow 级别优先级和Alert window 具有 Alert UIWindowLevel 优先级,因为我希望始终将警报置于主 UIWindow 上模态呈现的任何 ViewController 之上(AppDelegates 参考).我还有另一个具有状态栏优先级的 UIWindow,在我确实想要一个不同的时刻 ViewController 最重要的是。 因此,当我向 UIWindow 显示 Alert UIWIndowLevel 优先级并且在我向状态栏 UIWIndowLevel 显示不同的 window 后,Alert Window 中的警报显示在状态栏 window。这有什么原因吗?

An example app screenshot I built to test in

所以,我查看了打开的许多 SO 中的一些并看到了这个答案:

我打印的 (UIWindowLevelNormal, UIWindowLevelAlert, UIWindowLevelStatusBar) 的值是 (0.0, 2000.0, 1000.0)。但是 Apple 的文档指出:

let UIWindowLevelNormal: UIWindowLevel

The default level. Use this level for the majority of your content, including for your app’s main window.

let UIWindowLevelAlert: UIWindowLevel

The level for an alert view. Windows at this level appear on top of windows at the UIWindowLevelNormal level.

let UIWindowLevelStatusBar: UIWindowLevel

The level for a status window. Windows at this level appear on top of windows at the UIWindowLevelAlert level.

我在 Apple 的 Bug Reporter 中填写了一个错误。

我的解决方案是创建一个值超过 2000 的 CGFloat 并将其添加到 windowLevel。