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

images from library have wrong order #251

Closed
sergJozee opened this issue Nov 22, 2016 · 5 comments
Closed

images from library have wrong order #251

sergJozee opened this issue Nov 22, 2016 · 5 comments

Comments

@sergJozee
Copy link

When i pick images from the library i do not get the images to show in the correct order. The first image i pick from library does not always show as first image in the list with chosen images.
schermafbeelding 2016-11-22 om 14 50 16
schermafbeelding 2016-11-22 om 14 52 34

@DesmondDAI
Copy link

@sergJozee I met the same problem. I pick the according index using enumerated()

@zhangao0086
Copy link
Owner

zhangao0086 commented Mar 23, 2017

@sergJozee @DesmondDAI Could you post your code about show chosen images?

@DesmondDAI
Copy link

@zhangao0086

I tried to multi select photos:

let pickerController = DKImagePickerController()
pickerController.assetType = .AllPhotos
pickerController.showsCancelButton = true
pickerController.maxSelectableCount = 5

pickerController.didSelectAssets = { (assets: [DKAsset]) in
    for (index, asset) in self.selectedImageAssets.enumerate() {
        asset.fetchImageWithSize(CGSizeMake(512, 512), options: getImageRequestOptions(), contentMode: PHImageContentMode.AspectFill, completeBlock: {
            (image, info) in
            print("index: \(index)")
        })
    }
}

And the function getImageRequestOptions():

private func getImageRequestOptions() -> PHImageRequestOptions {
    let options = PHImageRequestOptions()
    options.deliveryMode = PHImageRequestOptionsDeliveryMode.HighQualityFormat
    options.networkAccessAllowed = true
    return options
}

The printed index is out of order. e.g. 3 1 2 0

@zhangao0086
Copy link
Owner

Hi @DesmondDAI
The fetchImageWithSize is an asynchronous method. It will get images from your device or iCloud, so the callback order is not guaranteed.

@anphanngocvn
Copy link

Update: using this method and then it should work well.
public func fetchFullScreenImage(sync: Bool, completeBlock: (image: UIImage?, info: [NSObject : AnyObject]?) -> Void)

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

No branches or pull requests

5 participants