Search code examples
iosobjective-cuiimagepickercontroller

Order media in ascending mode QBImagePickerController


I'm using QBImagePickerController to allow user to select images from gallery.

QBImagePickerController *imagePickerController = [QBImagePickerController new];
imagePickerController.delegate = self;
imagePickerController.mediaType = QBImagePickerMediaTypeImage;
imagePickerController.allowsMultipleSelection = YES;
imagePickerController.showsNumberOfSelectedAssets = YES;
self.imagePickerControllerImages = imagePickerController;

[self presentViewController:self.imagePickerControllerImages animated:YES completion:NULL];

The only issue is that images are ordered in ascending mode, that means the older images are presented first, the user needs to scroll until the end to reach the newest images every time.

Is there a way to order in descending mode?

Like Facebook and WhatsApp that let you choose images starting by the newest.


Solution

  • One-line fix in QBAssetsViewController.m:

    options.sortDescriptors = @[[NSSortDescriptor sortDescriptorWithKey:@"creationDate" ascending:NO]];
    self.fetchResult = [PHAsset fetchAssetsInAssetCollection:self.assetCollection options:options];