From 848d8e9d181916bdf6615a0cbdcc26f4dc382355 Mon Sep 17 00:00:00 2001 From: Khoa Pham Date: Thu, 22 Sep 2016 15:55:00 +0200 Subject: [PATCH 1/2] Use HighestQuality to avoid successive callbacks --- Source/AssetManager.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/AssetManager.swift b/Source/AssetManager.swift index f9b7b6d0..de807851 100644 --- a/Source/AssetManager.swift +++ b/Source/AssetManager.swift @@ -43,9 +43,10 @@ public class AssetManager { public static func resolveAsset(asset: PHAsset, size: CGSize = CGSize(width: 720, height: 1280), completion: (image: UIImage?) -> Void) { let imageManager = PHImageManager.defaultManager() let requestOptions = PHImageRequestOptions() + requestOptions.deliveryMode = .HighQualityFormat imageManager.requestImageForAsset(asset, targetSize: size, contentMode: .AspectFill, options: requestOptions) { image, info in - if let info = info where info["PHImageFileUTIKey"] == nil { + if let info = info { dispatch_async(dispatch_get_main_queue(), { completion(image: image) }) From 35ae57b064a6ddde0fd0789de59068f673a37a39 Mon Sep 17 00:00:00 2001 From: Khoa Pham Date: Thu, 22 Sep 2016 15:55:13 +0200 Subject: [PATCH 2/2] Use smaller size as this is for stack view --- Source/ImageGallery/ImageGalleryView.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/ImageGallery/ImageGalleryView.swift b/Source/ImageGallery/ImageGalleryView.swift index b8257484..7459370b 100644 --- a/Source/ImageGallery/ImageGalleryView.swift +++ b/Source/ImageGallery/ImageGalleryView.swift @@ -193,7 +193,7 @@ extension ImageGalleryView: UICollectionViewDelegate { let asset = assets[indexPath.row] - AssetManager.resolveAsset(asset) { image in + AssetManager.resolveAsset(asset, size: CGSize(width: 100, height: 100)) { image in guard let _ = image else { return } if cell.selectedImageView.image != nil {