Skip to content
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

Merged
merged 21 commits into from
Oct 5, 2015

Conversation

zenangst
Copy link
Contributor

@zenangst zenangst commented Oct 5, 2015

No description provided.

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 {
Copy link
Contributor Author

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.)

http://stackoverflow.com/questions/27670325/photos-framework-requestimageforasset-returning-two-results-cant-set-image-vi

@hyperoslo/mystore-ios

requestOptions.synchronous = true

for asset in assets {
imageManager.requestImageForAsset(asset, targetSize: size, contentMode: PHImageContentMode.AspectFill, options: requestOptions, resultHandler: { image, info in
Copy link
Contributor

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 😃

@vadymmarkov
Copy link
Contributor

@zenangst Made some comments, except of that looks good for me.

@RamonGilabert
Copy link
Contributor

It looks good to me!

Christoffer Winterkvist added 2 commits October 5, 2015 13:16
@zenangst
Copy link
Contributor Author

zenangst commented Oct 5, 2015

@vadymmarkov fixed your comments

@vadymmarkov
Copy link
Contributor

@zenangst 🌟

vadymmarkov added a commit that referenced this pull request Oct 5, 2015
Lookup asynchronously and use PHAssets instead of UIImages
@vadymmarkov vadymmarkov merged commit ba8751e into master Oct 5, 2015
@vadymmarkov vadymmarkov deleted the perfect/photos-library-lookup branch October 5, 2015 11:20
@zenangst zenangst restored the perfect/photos-library-lookup branch October 5, 2015 11:22
@RamonGilabert
Copy link
Contributor

Why is this branch restored?

@zenangst zenangst deleted the perfect/photos-library-lookup branch October 5, 2015 12:01
@zenangst
Copy link
Contributor Author

zenangst commented Oct 5, 2015

@RamonGilabert I think I push to it by accident

@ghost
Copy link

ghost commented Aug 3, 2016

Does this mean that we can have [PHAsset] instead of [UIImage] for wrapperDidPress and doneButtonDidPress ?

@onmyway133
Copy link
Contributor

@mosn As of https://github.com/hyperoslo/ImagePicker/blob/master/Source/ImagePickerController.swift

You can see that it returns UIImage

public protocol ImagePickerDelegate: class {

  func wrapperDidPress(imagePicker: ImagePickerController, images: [UIImage])
  func doneButtonDidPress(imagePicker: ImagePickerController, images: [UIImage])
  func cancelButtonDidPress(imagePicker: ImagePickerController)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants