From 3544d0fdf89e5bdad1bc16701fcb875284905b4a Mon Sep 17 00:00:00 2001 From: Mauro Date: Fri, 4 Aug 2017 14:04:49 +0200 Subject: [PATCH] Added sorting by creationDate asc and desc --- QBImagePicker/QBAlbumsViewController.m | 2 ++ QBImagePicker/QBAssetsViewController.m | 2 ++ QBImagePicker/QBImagePickerController.h | 1 + 3 files changed, 5 insertions(+) diff --git a/QBImagePicker/QBAlbumsViewController.m b/QBImagePicker/QBAlbumsViewController.m index a08dfe28..e23c5661 100644 --- a/QBImagePicker/QBAlbumsViewController.m +++ b/QBImagePicker/QBAlbumsViewController.m @@ -295,6 +295,8 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N default: break; } + + options.sortDescriptors = @[[NSSortDescriptor sortDescriptorWithKey:@"creationDate" ascending: self.imagePickerController.sortMediaByCreationDateAscending]]; PHFetchResult *fetchResult = [PHAsset fetchAssetsInAssetCollection:assetCollection options:options]; PHImageManager *imageManager = [PHImageManager defaultManager]; diff --git a/QBImagePicker/QBAssetsViewController.m b/QBImagePicker/QBAssetsViewController.m index 98177684..3b647878 100644 --- a/QBImagePicker/QBAssetsViewController.m +++ b/QBImagePicker/QBAssetsViewController.m @@ -246,6 +246,8 @@ - (void)updateFetchRequest default: break; } + + options.sortDescriptors = @[[NSSortDescriptor sortDescriptorWithKey:@"creationDate" ascending: self.imagePickerController.sortMediaByCreationDateAscending]]; self.fetchResult = [PHAsset fetchAssetsInAssetCollection:self.assetCollection options:options]; diff --git a/QBImagePicker/QBImagePickerController.h b/QBImagePicker/QBImagePickerController.h index e7547e59..d9f802c3 100644 --- a/QBImagePicker/QBImagePickerController.h +++ b/QBImagePicker/QBImagePickerController.h @@ -37,6 +37,7 @@ typedef NS_ENUM(NSUInteger, QBImagePickerMediaType) { @property (nonatomic, copy) NSArray *assetCollectionSubtypes; @property (nonatomic, assign) QBImagePickerMediaType mediaType; +@property (nonatomic, assign) BOOL sortMediaByCreationDateAscending; @property (nonatomic, assign) BOOL allowsMultipleSelection; @property (nonatomic, assign) NSUInteger minimumNumberOfSelection;