我在iOS 13上有一个UISplitViewController
怪异的错误(在iOS 12上很好用)。我创建了一个简单的项目来重现此错误。
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
宽度。如果运行此项目,则会得到以下结果:
maximumPrimaryColumnWidth = max(screenSize.width, screenSize.height)
到
maximumPrimaryColumnWidth = max(screenSize.width - 1, screenSize.height - 1)
我得到了我想要的东西:
有什么主意吗?谢谢。