-
Notifications
You must be signed in to change notification settings - Fork 677
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
iCloud Support #79
Comments
Hey @diegof29, thanks for bringing this to our attentions, we will do some digging to see what we come up with. What happens when try to select something from iCloud? Do you get any warnings or errors in the logs? |
Hi @zenangst! I did a quick debug and I found that in ImagePicker/ImageGalleryView.swift in collectionView:didSelectItemAtIndexPath the block is called more than one time if I select an iCloud image and that results on a selection and a quick deselection of the image. |
@diegof29 still haven't had the time to look into this properly I'm afraid. If you do solve it before we do, feel free to make a pull request. |
+1 for support |
app crash if I pick a picture from iCloud. Does this library have support for getting iCloud pictures? |
+1 |
@aitornillooo @weakfl Hi, what crash log is it? |
@onmyway133 Sorry if my answer was misleading. The app doesn't crash, but images get immediately deselected as @diegof29 has described. |
I did a little debugging and it turns out the
It turns out that the completion block is executed 3 times if the image is on the device, so the image ends up selected by favourable circumstances ;) What's the reason you're resolving assets on Unfortunately I couldn't really test with iCloud images because for some reason they're not included in the gallery view on iOS 10. I don't know if EDIT: I would suggest to add an public static func fetch(completion: (assets: [PHAsset]) -> Void) {
let fetchOptions = PHFetchOptions()
fetchOptions.sortDescriptors = [NSSortDescriptor(key:"creationDate", ascending: true)]
let authorizationStatus = PHPhotoLibrary.authorizationStatus()
var fetchResult: PHFetchResult?
guard authorizationStatus == .Authorized else { return }
if fetchResult == nil {
fetchResult = PHAsset.fetchAssetsWithMediaType(.Image, options: fetchOptions)
}
if fetchResult?.count > 0 {
var assets = [PHAsset]()
fetchResult?.enumerateObjectsUsingBlock { object, index, stop in
if let asset = object as? PHAsset {
assets.insert(asset, atIndex: 0)
}
}
dispatch_async(dispatch_get_main_queue(), {
completion(assets: assets)
})
}
} I've also removed the public func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
guard let cell = collectionView.cellForItemAtIndexPath(indexPath)
as? ImageGalleryViewCell else { return }
let asset = assets[indexPath.row]
if cell.selectedImageView.image != nil {
UIView.animateWithDuration(0.2, animations: {
cell.selectedImageView.transform = CGAffineTransformMakeScale(0.1, 0.1)
}) { _ in
cell.selectedImageView.image = nil
}
self.selectedStack.dropAsset(asset)
} else if self.imageLimit == 0 || self.imageLimit > self.selectedStack.assets.count {
cell.selectedImageView.image = AssetManager.getImage("selectedImageGallery")
cell.selectedImageView.transform = CGAffineTransformMakeScale(0, 0)
UIView.animateWithDuration(0.2) { _ in
cell.selectedImageView.transform = CGAffineTransformIdentity
}
self.selectedStack.pushAsset(asset)
}
} Images from the iCloud photo library do work with these changes, but imho this is only a partial solution. |
@zenangst @onmyway133 Take a look at my previous comment for a partial solution. |
The photo selection doesn't work if the user picks a photo from iCloud.
The text was updated successfully, but these errors were encountered: