Fix collection view cells not deselecting in split nav controller on iPad

This commit is contained in:
Shadowfacts 2022-10-10 18:56:40 -04:00
parent dcc8f38f3d
commit 1ac72bc363
1 changed files with 6 additions and 0 deletions

View File

@ -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)