Fix crash when split VC collapses with multi-column nav controller

This commit is contained in:
Shadowfacts 2023-09-05 20:47:11 -04:00
parent 88105f22a0
commit f1a6a405c2
2 changed files with 7 additions and 2 deletions

View File

@ -169,6 +169,7 @@ extension MainSplitViewController: UISplitViewControllerDelegate {
var itemNavStack: [UIViewController]
if item == sidebar.selectedItem {
itemNavStack = secondaryNavController.viewControllers
secondaryNavController.viewControllers = []
} else {
itemNavStack = navigationStacks[item] ?? []
navigationStacks.removeValue(forKey: item)

View File

@ -121,8 +121,12 @@ class MultiColumnNavigationController: UIViewController {
}
private func scrollToEnd(animated: Bool) {
if viewControllers.isEmpty {
scrollView.setContentOffset(.init(x: -scrollView.adjustedLeadingContentInset, y: -scrollView.adjustedContentInset.top), animated: false)
} else {
scrollColumnToEnd(columnIndex: viewControllers.count - 1, animated: animated)
}
}
private func scrollColumnToEnd(columnIndex: Int, animated: Bool) {
scrollView.layoutIfNeeded()
@ -233,7 +237,7 @@ private class ColumnView: UIView {
}
func setContent(_ viewController: UIViewController, needsCloseButton: Bool) {
guard viewController !== contentViewController else {
guard viewController !== contentViewController || viewController.parent !== navigationController else {
return
}