Skip to content

Commit

Permalink
BugFix: single selection mode #189
Browse files Browse the repository at this point in the history
  • Loading branch information
tilltue committed Jul 17, 2019
1 parent a8b8080 commit bdb091f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion TLPhotoPicker.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = 'TLPhotoPicker'
s.version = '1.9.2'
s.version = '1.9.3'
s.summary = 'multiple phassets picker for iOS lib. like facebook'

# This description is used to generate tags and improve search results.
Expand Down
16 changes: 12 additions & 4 deletions TLPhotoPicker/Classes/TLPhotosPickerViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -247,15 +247,23 @@ open class TLPhotosPickerViewController: UIViewController {
}
}

private func findIndexAndReloadCells(phAsset: PHAsset) {
if
var index = self.focusedCollection?.fetchResult?.index(of: phAsset),
index != NSNotFound
{
index += (getfocusedIndex() == 0 && self.configure.usedCameraButton) ? 1 : 0
self.collectionView.reloadItems(at: [IndexPath(row: index, section: 0)])
}
}

open func deselectWhenUsingSingleSelectedMode() {
if
self.configure.singleSelectedMode == true,
let selectedPHAsset = self.selectedAssets.first?.phAsset,
var index = self.focusedCollection?.fetchResult?.index(of: selectedPHAsset)
let selectedPHAsset = self.selectedAssets.first?.phAsset
{
index += self.configure.usedCameraButton ? 1 : 0
self.selectedAssets.removeAll()
self.collectionView.reloadItems(at: [IndexPath(row: index, section: 0)])
findIndexAndReloadCells(phAsset: selectedPHAsset)
}
}

Expand Down

0 comments on commit bdb091f

Please sign in to comment.