1

我正在为支持横向和纵向模式的 iPad 和 iPhone 设备开发通用应用程序。在横向模式下,除了纵向模式外,它还有更多按钮。

对于 iPhone,我能够使用情节提要设计不同的布局,并且对于 wC|hC、wC|hR、wR|hC,它可以按预期工作。

但是在 iPad 的情况下,我无法设计不同的布局,因为横向和纵向的尺寸等级是相同的 wR|hR。

我提到了@Sizing class for iPad portrait and Landscape Modes讨论的解决方案,iPad Landscape 和 Portrait 不同的布局与 Size Class并尝试使用以下代码:

override func overrideTraitCollectionForChildViewController(childViewController: UIViewController) -> UITraitCollection? {
    if UIDevice.currentDevice().userInterfaceIdiom == UIUserInterfaceIdiom.Pad &&
        view.bounds.width > view.bounds.height {

        let collections = [UITraitCollection(horizontalSizeClass: .Regular),
                           UITraitCollection(verticalSizeClass: .Compact)]
        return UITraitCollection(traitsFromCollections: collections)

    }
    return super.overrideTraitCollectionForChildViewController(childViewController)
}

但是这段代码从未被调用过。实现这一目标的更好方法应该是什么?

是否会以编程方式为 iPad 更改特征对应用程序批准过程有任何影响,因为 Apple 本身在横向和纵向中为 iPad 提供了相同的尺寸等级。

4

0 回答 0