From 23ebaeb6480533ccd22db43d9315de5e4cc03871 Mon Sep 17 00:00:00 2001 From: "wade.hawk" Date: Thu, 4 Jul 2019 13:42:15 +0900 Subject: [PATCH] Bug fix: #188 --- TLPhotoPicker.podspec | 2 +- .../Classes/TLPhotosPickerViewController.swift | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/TLPhotoPicker.podspec b/TLPhotoPicker.podspec index 7b814d3a..21651ac9 100644 --- a/TLPhotoPicker.podspec +++ b/TLPhotoPicker.podspec @@ -8,7 +8,7 @@ Pod::Spec.new do |s| s.name = 'TLPhotoPicker' - s.version = '1.9.0' + s.version = '1.9.1' s.summary = 'multiple phassets picker for iOS lib. like facebook' # This description is used to generate tags and improve search results. diff --git a/TLPhotoPicker/Classes/TLPhotosPickerViewController.swift b/TLPhotoPicker/Classes/TLPhotosPickerViewController.swift index 3ae4ca83..5e8763c7 100644 --- a/TLPhotoPicker/Classes/TLPhotosPickerViewController.swift +++ b/TLPhotoPicker/Classes/TLPhotosPickerViewController.swift @@ -247,11 +247,19 @@ open class TLPhotosPickerViewController: UIViewController { } } - open func maxCheck() -> Bool { - if self.configure.singleSelectedMode { + open func deselectWhenUsingSingleSelectedMode() { + if + self.configure.singleSelectedMode == true, + let selectedPHAsset = self.selectedAssets.first?.phAsset, + let index = self.focusedCollection?.fetchResult?.index(of: selectedPHAsset) + { self.selectedAssets.removeAll() - self.orderUpdateCells() + self.collectionView.reloadItems(at: [IndexPath(row: index, section: 0)]) } + } + + open func maxCheck() -> Bool { + deselectWhenUsingSingleSelectedMode() if let max = self.configure.maxSelectedAssets, max <= self.selectedAssets.count { self.delegate?.didExceedMaximumNumberOfSelection(picker: self) self.didExceedMaximumNumberOfSelection?(self)