7

I have a weird bug with UISplitViewController on iOS 13 (it works fine on iOS 12). I created a simple project to reproduce this bug.

  • This app looks as follow, nothing fancy: enter image description here

  • I subclassed UISplitViewController as follow to allow resizing the 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
    }
}

Whenever I load the SplitViewController, I want to expand the MasterViewController to the full UIScreen width. If I run this project, I get this result:

enter image description here

  • Now if I change the line:
maximumPrimaryColumnWidth = max(screenSize.width, screenSize.height)

to

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

I obtain what I want:

enter image description here

Any idea? Thanks.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
DrS
  • 326
  • 1
  • 4

0 Answers0