From 1ac72bc363b8cfcac27870cfe4c84172258abd8b Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Mon, 10 Oct 2022 18:56:40 -0400 Subject: [PATCH] Fix collection view cells not deselecting in split nav controller on iPad --- Tusker/Screens/Utilities/SplitNavigationController.swift | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Tusker/Screens/Utilities/SplitNavigationController.swift b/Tusker/Screens/Utilities/SplitNavigationController.swift index cf7926d3..4fc7c1d4 100644 --- a/Tusker/Screens/Utilities/SplitNavigationController.swift +++ b/Tusker/Screens/Utilities/SplitNavigationController.swift @@ -55,6 +55,12 @@ class SplitNavigationController: UIViewController { if let tableVC = sender as? UITableViewController, let selectedIndexPath = tableVC.tableView.indexPathForSelectedRow { tableVC.tableView.deselectRow(at: selectedIndexPath, animated: true) + } else if let sender = sender as? UIViewController, + let collectionView = sender.view as? UICollectionView { + // the collection view's animation speed is weirdly fast, so we do it slower + UIView.animate(withDuration: 0.5, delay: 0) { + collectionView.indexPathsForSelectedItems?.forEach { collectionView.deselectItem(at: $0, animated: false) } + } } } else { self.rootNav.pushViewController(vc, animated: true)