iOS 13-UISplitViewController调整大小错误

时间:2019-10-15 16:25:33

标签: ios swift uisplitviewcontroller ios13

我在iOS 13上有一个UISplitViewController怪异的错误(在iOS 12上很好用)。我创建了一个简单的项目来重现此错误。

  • 此应用程序外观如下,没什么花哨的: enter image description here

  • 我将UISplitViewController分为以下子类,以允许调整MasterViewController的大小:

final class SplitViewController: UISplitViewController {
    override public func viewDidLoad() {
        super.viewDidLoad()
        preferredDisplayMode = .allVisible
        delegate = self
        expandMasterView()
    }

    private func expandMasterView() {
        preferredPrimaryColumnWidthFraction = 1
        let screenSize = UIScreen.main.bounds.size
        maximumPrimaryColumnWidth = max(screenSize.width, screenSize.height)
    }
}

extension SplitViewController: UISplitViewControllerDelegate {
    func splitViewController(_ splitViewController: UISplitViewController,
                             collapseSecondary secondaryViewController: UIViewController,
                             onto primaryViewController: UIViewController) -> Bool {
        return true
    }
}

无论何时加载SplitViewController,我都想将MasterViewController扩展到完整的UIScreen宽度。如果运行此项目,则会得到以下结果:

enter image description here

  • 现在,如果我换行:
maximumPrimaryColumnWidth = max(screenSize.width, screenSize.height)

maximumPrimaryColumnWidth = max(screenSize.width - 1, screenSize.height - 1)

我得到了我想要的东西:

enter image description here

有什么主意吗?谢谢。

0 个答案:

没有答案