gpt4 book ai didi

ios - 检测主视图 Controller 和详细 View Controller 何时都在屏幕上?

转载 作者:技术小花猫 更新时间:2023-10-29 10:45:06 26 4
gpt4 key购买 nike

我已经在 Xcode 6 中使用通用 Storyboard 实现了一个 UISplitViewController。现在运行 iOS 8 的 iPhone 支持 UISplitViewController,默认情况下只会打开一个 View Controller 一次筛选。

我需要知道主视图 Controller 和详细 View Controller 何时都在屏幕上 (iPad)。如果两者都在屏幕上,我需要从 UITableViewCell 中删除披露指示器 - 仅当只有主视图 Controller 在屏幕上(iPhone)时才呈现它们,就像设置应用程序一样。

我可以简单地检测设备并仅在它是 iPhone 时添加它们,但不推荐这样做。新设备有可能只显示一个 View Controller ,而不识别为手机。另一个想法是检测 self.splitViewController 是否为 nil,但这行不通,因为它在 iPhone 和 iPhone 上都不是 nil iPad,因为它实际上位于 iPhone 上的 Split View Controller 中。

是否可以检测主视图 Controller 和详细 View Controller 何时同时在屏幕上可见?

最佳答案

UISplitViewController

@property(nonatomic, readonly, getter=isCollapsed) BOOL 折叠

This property is set to YES when the split view controller content is semantically collapsed into a single container. Collapsing happens when the split view controller transitions from a horizontally regular to a horizontally compact environment. After it has been collapsed, the split view controller reports having only one child view controller in its viewControllers property. The other view controller is collapsed into the other view controller’s content with the help of the delegate object or discarded temporarily. When collapsed, the displayMode property has no impact on the appearance of the split view controller interface.

The value of this property is NO when the split view controller is capable of displaying both of its child view controllers at the same time, even if it is not showing them both at the moment. In this expanded mode, the split view controller’s configuration of its child view controllers is determined by the displayMode property. In addition, the viewControllers property contains both the primary and secondary view controllers.

During a transition from an expanded to collapsed interface, the value of this property is NO until after the collapse transition finishes and all of the relevant delegate methods have been called. Similarly, when transitioning back to an expanded interface, the value is YES until the transition finishes.

来自类引用。

感谢 Frederik A. Winkelsdorf:

It should be noted that .collapsed also reports false if a DetailViewController is zoomed to cover the full screen. If you really want to know if both are visible, check beside the .collapsed property for splitViewController.displayMode ==
UISplitViewControllerDisplayMode.AllVisible.
I found it useful when dealing with iPhone 6 Plus Landscape layouts.

关于ios - 检测主视图 Controller 和详细 View Controller 何时都在屏幕上?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25436387/

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