-
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
Lookup asynchronously and use PHAssets instead of UIImages #41
Conversation
This method will resolve PHAssets into images asynchronously
let requestOptions = PHImageRequestOptions() | ||
|
||
imageManager.requestImageForAsset(asset, targetSize: size, contentMode: PHImageContentMode.AspectFill, options: requestOptions, resultHandler: { image, info in | ||
if let info = info where info["PHImageFileUTIKey"] == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bit dirty but it helps it from not calling the completion twice. This has to do with how requestImageForAsset
resolves assets.
For an asynchronous request, Photos may call your result handler block more than once. Photos first calls the block to provide a low-quality image suitable for displaying temporarily while it prepares a high-quality image. (If low-quality image data is immediately available, the first call may occur before the method returns.)
@hyperoslo/mystore-ios
requestOptions.synchronous = true | ||
|
||
for asset in assets { | ||
imageManager.requestImageForAsset(asset, targetSize: size, contentMode: PHImageContentMode.AspectFill, options: requestOptions, resultHandler: { image, info in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think should also work without resultHandler
😃
@zenangst Made some comments, except of that looks good for me. |
It looks good to me! |
@vadymmarkov fixed your comments |
Lookup asynchronously and use PHAssets instead of UIImages
Why is this branch restored? |
@RamonGilabert I think I push to it by accident |
Does this mean that we can have [PHAsset] instead of [UIImage] for |
@mosn As of https://github.com/hyperoslo/ImagePicker/blob/master/Source/ImagePickerController.swift You can see that it returns public protocol ImagePickerDelegate: class {
func wrapperDidPress(imagePicker: ImagePickerController, images: [UIImage])
func doneButtonDidPress(imagePicker: ImagePickerController, images: [UIImage])
func cancelButtonDidPress(imagePicker: ImagePickerController)
} |
No description provided.