gpt4 book ai didi

ios - UIWindow 状态栏旋转

转载 作者:塔克拉玛干 更新时间:2023-11-01 21:20:34 28 4
gpt4 key购买 nike

我有一个应用程序,其中有两个 UIWindow 实例的用例。第一个实例运行所有正常的应用程序交互,但我需要能够在没有用户交互的情况下,无论用户在应用程序中做什么,都能够在所有其他内容之上呈现一个 View Controller 。

我让第二个窗口正常工作并且呈现良好。在这个 View Controller 中,我只支持纵向模式(虽然应用程序的其他部分支持横向)。我尝试在窗口的 rootViewController 中使用这些方法来阻止旋转:

override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {
return [.Portrait]
}

override func shouldAutorotate() -> Bool {
return false
}

这成功地阻止了设备旋转 View Controller ,但它仍然允许状态栏旋转。我也想防止状态栏旋转。我尝试将以下内容添加到我的 AppDelegate

func application(application: UIApplication, supportedInterfaceOrientationsForWindow window: UIWindow?) -> UIInterfaceOrientationMask {
if let _ = window as? MyTopWindow {
return [.Portrait]
} else {
return .All
}
}

但是这也没有用。状态栏仍然旋转。

我已经看到下面的问题并尝试实现解决方案,但它不适用于我的情况:Status bar rotates separated from UIWindow

编辑

这是我创建 UIWindow 的代码:

self.callManagementWindow = ActiveCallManagementWindow(frame: UIScreen.mainScreen().bounds)
self.callManagementWindow.rootViewController = primaryViewController
self.callManagementWindow.hidden = false
self.callManagementWindow.makeKeyAndVisible()

最佳答案

前段时间我也有两个窗口和旋转的问题,如果我没记错的话你需要覆盖 rootViewController 中的 supportedInterfaceOrientations()shouldAutorotate() 第一个 UIWindow 和第二个

关于ios - UIWindow 状态栏旋转,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37082776/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com