Skip to content

Commit

Permalink
1.0.23
Browse files Browse the repository at this point in the history
the new release version: 0.1.1
memory problem solved
  • Loading branch information
cloxnu committed Nov 4, 2019
1 parent 8a3f003 commit cf6c500
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 10 deletions.
Binary file modified .DS_Store
Binary file not shown.
Binary file modified ConvenientImagePicker/.DS_Store
Binary file not shown.
9 changes: 7 additions & 2 deletions ConvenientImagePicker/Classes/PickerViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public class PickerViewController: UIViewController {
var assetsFetchResults: PHFetchResult<PHAsset>!
var imageManager: PHCachingImageManager!

var selectedImages = [Int : UIImage]()
var selectedImagesIndex = Set<Int>()


public override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
Expand Down Expand Up @@ -238,7 +238,12 @@ public class PickerViewController: UIViewController {
self.mainView.frame = CGRect(x: 0, y: screenHeight, width: screenWidth, height: screenHeight + 50.0)
self.backView.alpha = 0
}) { (true) in
self.delegate?.imagePickerDidCancel(self.selectedImages)
var selectedImages = [Int : UIImage]()
for oneIndex in self.selectedImagesIndex
{
selectedImages[oneIndex] = self.GetImageFromIndex(item: oneIndex)
}
self.delegate?.imagePickerDidCancel(selectedImages)
self.dismiss(animated: true, completion: nil)
}
}
Expand Down
18 changes: 10 additions & 8 deletions ConvenientImagePicker/Classes/PickerViewDataSource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,15 @@ extension PickerViewController: UICollectionViewDelegateFlowLayout, UICollection
{
guard let cell = self.collectionView.dequeueReusableCell(withReuseIdentifier: "PickerCollectionCell", for: indexPath) as? PickerCollectionCell else { return UICollectionViewCell() }
cell.image.layer.borderColor = UIColor.systemBlue.cgColor
cell.image.layer.borderWidth = self.selectedImages[indexPath.item] == nil ? 0.0 : 3.0
cell.selectedImageView.alpha = self.selectedImages[indexPath.item] == nil ? 0 : 1
cell.upper.alpha = self.selectedImages[indexPath.item] == nil ? 0 : 0.3
cell.image.layer.borderWidth = self.selectedImagesIndex.contains(indexPath.item) ? 3.0 : 0.0
cell.selectedImageView.alpha = self.selectedImagesIndex.contains(indexPath.item) ? 1 : 0
cell.upper.alpha = self.selectedImagesIndex.contains(indexPath.item) ? 0.3 : 0

if self.images == nil
{
let asset = self.assetsFetchResults[indexPath.item]
//获取缩略图
self.imageManager.requestImage(for: asset, targetSize: CGSize(width: 500, height: 500),
self.imageManager.requestImage(for: asset, targetSize: CGSize(width: 200, height: 200),
contentMode: PHImageContentMode.aspectFill,
options: nil) { (image, nfo) in
cell.image.image = image
Expand Down Expand Up @@ -179,8 +179,9 @@ extension PickerViewController: UICollectionViewDelegateFlowLayout, UICollection
func PickerCollectionCellOp(indexPath: IndexPath)
{
let image = self.GetImageFromIndex(item: indexPath.item)
self.selectedImages[indexPath.item] = image
self._selectedImageCount = self.selectedImages.count
//self.selectedImages[indexPath.item] = image
self.selectedImagesIndex.insert(indexPath.item)
self._selectedImageCount = self.selectedImagesIndex.count
self.delegate?.imageDidSelect(self, index: indexPath.item, image: image)
self.CountViewUpdate()
if !self.allowMultipleSelection
Expand All @@ -192,8 +193,9 @@ extension PickerViewController: UICollectionViewDelegateFlowLayout, UICollection
func PickerCollectionCellDeOp(indexPath: IndexPath)
{
let image = self.GetImageFromIndex(item: indexPath.item)
self.selectedImages[indexPath.item] = nil
self._selectedImageCount = self.selectedImages.count
//self.selectedImages[indexPath.item] = nil
self.selectedImagesIndex.remove(indexPath.item)
self._selectedImageCount = self.selectedImagesIndex.count
self.delegate?.imageDidDeselect(self, index: indexPath.item, image: image)
self.CountViewUpdate()
}
Expand Down
Binary file modified Documentation/.DS_Store
Binary file not shown.
Binary file not shown.

0 comments on commit cf6c500

Please sign in to comment.