ios - 多个 UIWindows 以及哪个控制状态栏方向

标签 ios iphone objective-c

如果您的应用有一个 UIWindow,我的理解是 UIWindowrootViewController 将是 UIViewController 接收旋转/方向方法,如 shouldAutoRotateshouldAutoRotateToInterfaceOrientation 等。

我正在编写一个外部库,并且有一个实例,我在其中创建了另一个 UIWindow 对象,设置了它的 rootViewController,并使其成为关键且可见。看起来原始窗口的 rootViewController 仍然是发送旋转方法的那个,而不是新的。

我希望能够控制应用程序是否可以在新窗口可见时旋转,但似乎原始窗口的 rootViewController 仍然可以控制它。我已经尝试将原始窗口的 rootViewController 设置为 rootViewController ,在我的新窗口可见时禁止旋转屏幕并重置原始窗口的 rootViewController 到它原来的 rootViewController 但这会导致它自己的一些问题。

有谁知道如何让某个 UIViewController 负责应用轮换?

最佳答案

您如何呈现新的 viewController?根据文档,唯一被询问 supportedInterfaceOrientations 的 viewControllers 是 Root View Controller ,或填充屏幕的 View Controller 。因此,在 iPhone 上,如果新的 viewController 正在填充屏幕(例如,以模态方式呈现),它应该会收到 supportedInterfaceOrientations 调用。

shouldAutoRotateToInterfaceOrientation 自 iOS 6 起已弃用,因此您应该改写 supportedInterfaceOrientations

关于ios - 多个 UIWindows 以及哪个控制状态栏方向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19919174/

相关文章:

iphone - 我们如何才能防止 iOS 6's upcoming UDID/UUID removal if we' 重新使用 PhoneGap?

iphone - NSMutableArray 没有将值传递给 CellForRowAtIndexPath?

iphone - 如何隐藏键盘 iPhone 应用程序

ios - object 不能为 nil - 在 segue 上?

ios - 核心数据 NSFetchedResultsController 和批量大小设置加载所有行

ios - 多声道音频 iOS(需要 4 个同时输入)

iOS 将字符串转换为日期 : hour is the same on two different times

ios - 您可以使用 springs & struts 为不同的设备调整 TableViewCell 的大小吗?

ios - 如何使用 referenceSizeForHeaderInSection 调整 collectionView header 的大小?

iphone - 将 NSString 与一堆字符串进行比较的更快/更简单的方法