From 65a4bad32fb3e460d4b328cc85eb9156df650aaa Mon Sep 17 00:00:00 2001 From: Moritz Lang Date: Thu, 7 Feb 2019 15:24:44 +0100 Subject: [PATCH] Select previously selected image when deselecting in multiselection --- Source/Pages/Gallery/YPLibraryVC+CollectionView.swift | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Source/Pages/Gallery/YPLibraryVC+CollectionView.swift b/Source/Pages/Gallery/YPLibraryVC+CollectionView.swift index fb59a54e4..690a52a4a 100644 --- a/Source/Pages/Gallery/YPLibraryVC+CollectionView.swift +++ b/Source/Pages/Gallery/YPLibraryVC+CollectionView.swift @@ -67,7 +67,15 @@ extension YPLibraryVC { } } v.collectionView.reloadItems(at: selectedIndexPaths) - + + // Replace the current selected image with the previously selected one + if let previouslySelectedIndexPath = selectedIndexPaths.last { + v.collectionView.deselectItem(at: indexPath, animated: false) + v.collectionView.selectItem(at: previouslySelectedIndexPath, animated: false, scrollPosition: []) + currentlySelectedIndex = previouslySelectedIndexPath.row + changeAsset(mediaManager.fetchResult[previouslySelectedIndexPath.row]) + } + checkLimit() } }