fix logic of photoPickedImageView.hidden when scroll

This commit is contained in:
nixzhu
2015-10-15 20:11:15 +08:00
committed by nixzhu
parent 44eff2c0a6
commit 2cfa6d0c63
2 changed files with 13 additions and 9 deletions
@@ -108,18 +108,23 @@ class PickPhotosViewController: UICollectionViewController, PHPhotoLibraryChange
}
override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCellWithReuseIdentifier(photoCellID, forIndexPath: indexPath) as! PhotoCell
cell.imageManager = imageManager
if let imageAsset = images[indexPath.item] as? PHAsset {
cell.imageAsset = imageAsset
cell.photoPickedImageView.hidden = !pickedImageSet.contains(imageAsset)
}
return cell
}
override func collectionView(collectionView: UICollectionView, willDisplayCell cell: UICollectionViewCell, forItemAtIndexPath indexPath: NSIndexPath) {
if let cell = cell as? PhotoCell {
cell.imageManager = imageManager
if let imageAsset = images[indexPath.item] as? PHAsset {
cell.imageAsset = imageAsset
cell.photoPickedImageView.hidden = !pickedImageSet.contains(imageAsset)
}
}
}
override func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
if let imageAsset = images[indexPath.item] as? PHAsset {
-1
View File
@@ -24,7 +24,6 @@ class PhotoCell: UICollectionViewCell {
self.imageManager?.requestImageForAsset(imageAsset, targetSize: CGSize(width: 80, height: 80), contentMode: .AspectFill, options: nil) { [weak self] image, info in
self?.photoImageView.image = image
self?.photoPickedImageView.hidden = !imageAsset.favorite
}
}
}