UISplitViewController - 双列样式不起作用

UISplitViewController - doubleColumn Style not working

在我的应用程序中,我使用这样的 UISplitViewController:

let splitViewController = UISplitViewController()
splitViewController.preferredDisplayMode = .oneBesideSecondary
splitViewController.viewControllers = [
    UINavigationController(rootViewController: CalendarViewController()),
    DetailViewController()
]

结果:

但是当我像这样将样式设置为 doubleColumn 时:

let splitViewController = UISplitViewController(style: .doubleColumn)

结果如下所示:

我不明白为什么现在 CalendarViewController 比主视图宽。我想使用边栏以便用户可以显示和隐藏日历。

如何修复此显示错误,使 CalendarViewController 与主视图具有相同的宽度?

这是 CalendarKit 库中的错误,已在以下提交中修复:Fix Layout Issue when using UISplitViewController

问题出在未考虑 safeArea 指南的布局代码中:

      dayHeaderView.frame = CGRect(origin: CGPoint(x: 0, y: layoutMargins.top),
                                   size: CGSize(width: bounds.width, height: headerHeight))
      let timelinePagerHeight = bounds.height - dayHeaderView.frame.maxY
      timelinePagerView.frame = CGRect(origin: CGPoint(x: 0, y: dayHeaderView.frame.maxY),
                                       size: CGSize(width: bounds.width, height: timelinePagerHeight))

切换到 AutoLayout 后,问题消失了:

      dayHeaderView.translatesAutoresizingMaskIntoConstraints = false
      timelinePagerView.translatesAutoresizingMaskIntoConstraints = false

      dayHeaderView.leadingAnchor.constraint(equalTo: safeAreaLayoutGuide.leadingAnchor).isActive = true
      dayHeaderView.trailingAnchor.constraint(equalTo: safeAreaLayoutGuide.trailingAnchor).isActive = true
      dayHeaderView.topAnchor.constraint(equalTo: safeAreaLayoutGuide.topAnchor).isActive = true
      let heightConstraint = dayHeaderView.heightAnchor.constraint(equalToConstant: headerHeight)
      heightConstraint.priority = .defaultLow
      heightConstraint.isActive = true

      timelinePagerView.leadingAnchor.constraint(equalTo: safeAreaLayoutGuide.leadingAnchor).isActive = true
      timelinePagerView.trailingAnchor.constraint(equalTo: safeAreaLayoutGuide.trailingAnchor).isActive = true
      timelinePagerView.topAnchor.constraint(equalTo: dayHeaderView.bottomAnchor).isActive = true
      timelinePagerView.bottomAnchor.constraint(equalTo: bottomAnchor).isActive = true