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.
I subclassed
UISplitViewController
as follow to allow resizing theMasterViewController
:
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:
- 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:
Any idea? Thanks.