Hello,
when opening the camera roll gallery, the scroll position is automatically set to the top of the gallery (oldest images / videos).
Is there a way to open the camera roll gallery at the bottom (most recent) images like the iOS native photos app?
Thank you so much for your help.
React native: 0.57.8
react-native-image-crop-picker: 0.24.1

I have the same problem brother, I have also published the same
https://github.com/ivpusic/react-native-image-crop-picker/issues/1089
I created a newly merged PR that allows you to modify the sort order, where you could sort the photos by creation date (newest first), would this help you @joshallison?
Note: this code is on master, it's not on any release yet
https://github.com/ivpusic/react-native-image-crop-picker/pull/1090
Creé un RP recién fusionado que te permite modificar el orden de clasificación, donde puedes ordenar las fotos por fecha de creación (la más nueva primero), ¿te ayudaría esto @joshallison ?
Nota: este código está en el maestro, aún no está en ninguna versión
thank you,
Could you show us an example of how to use it? we have tried using the new sortOrder configuration and we have not been successful with the order of the images
My code :
ImagePicker.openPicker({
compressImageQuality: 0.7,
compressImageMaxWidth: 1200,
mediaType: "photo",
includeBase64: true,
//smartAlbums: ["RecentlyAdded"]
sortOrder : "asc"
}).then(image => {
this.props.onCaptureImage(
{
uri: image.path,
type: image.mime, // or photo.type
name: image.filename || photo.jpg
}
);
this.onCancel();
}).catch((e) => {
this.onCancel();
});
You probably want “sortOrder: ‘desc’”. Since it’s by date of creation, the most recent dates are bigger and thus you must sort it the other way around. As it is right now, “asc” and “none”(default) are basically equal with the exception that the default order depends on the OS and thus might change over time.
~Miguel
On Aug 3, 2019, at 5:32 PM, jhondavila notifications@github.com wrote:
Could you show us an example of how to use it? we have tried using the new sortOrder configuration and we have not been successful with the order of the images
ImagePicker.openPicker({ compressImageQuality: 0.7, compressImageMaxWidth: 1200, mediaType: "photo", includeBase64: true, //smartAlbums: ["RecentlyAdded"] sortOrder : "asc" }).then(image => { this.props.onCaptureImage( { uri: image.path, type: image.mime, // or photo.type name: image.filename || photo.jpg } ); this.onCancel(); }).catch((e) => { this.onCancel(); });
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
I managed to solve the problem, I had to uninstall the dependency and reinstall it. apparently the npm was not updating the files correctly
Thanks for the support.
This is just a temporary solution if you don't want to update react-native and react-native-image-crop-picker version.
Open file: ios/Pods/QBImagePickerController/QBImagePicker/QBAssetsViewController.m
Search this line:
self.fetchResult = [PHAsset fetchAssetsInAssetCollection:self.assetCollection options:options];
Insert this line above it:
options.sortDescriptors = @[[NSSortDescriptor sortDescriptorWithKey:@"creationDate" ascending: NO]];
This is result
options.sortDescriptors = @[[NSSortDescriptor sortDescriptorWithKey:@"creationDate" ascending: NO]];
self.fetchResult = [PHAsset fetchAssetsInAssetCollection:self.assetCollection options:options];
@betranthanh this change should be added to the QBAssetsViewController.m for sure
no found react-native-image-crop-picker: 0.24.2 o 0.24.3 in npm
@betranthanh this change should be added to the QBAssetsViewController.m for sure
=> yep, that why I said: "This is just a temporary solution" ;)
@betranthanh I use this solution, but not working.
How can I solve this?
@betranthanh I use this solution, but not working.
How can I solve this?
I confirm the solution works well.
Guys, I tried to install the latest release of the package, but the desc sortOrder is not working there again. When do we expect to have a release with the fix?
Also @betranthanh, yes adding that line in ios/Pods/QBImagePickerController/QBImagePicker/QBAssetsViewController.m works. But what file in this repo should we change to have that line included in ios/Pods/QBImagePickerController/QBImagePicker/QBAssetsViewController.m file itself? I ask this because if we run rm -rf Pods, and then pod install, then the added line is not there already...
I tried to change QBAssetsViewController.m file in the package directly, but it does not add that line in ios/Pods/QBImagePickerController/QBImagePicker/QBAssetsViewController.m. Please help
@DavitVosk u can make post-install script to fix the code when you update pods.
How to patch files guide: http://stephenjungels.com/jungels.net/articles/diff-patch-ten-minutes.html
In case of this particular issue:
diff -u Pods/QBImagePickerController/QBImagePicker/QBAssetsViewController.m patches/QBAssetsViewController.m > patches/QBAssetsViewController.patch
A patches/QBAssetsViewController.m file is the same as you find in code, but with an added line that fixes sorting.
post_install do |installer|
puts 'Patching QBAssetsViewController'
%x(patch Pods/QBImagePickerController/QBImagePicker/QBAssetsViewController.m < patches/QBAssetsViewController.patch)
end
😃
@rosskhanas @betranthanh your solution works, however, in dark mode the gallery gets ugly, in conflict with this modification
https://github.com/ivpusic/react-native-image-crop-picker/issues/1105
Guys, do you know when are we getting an official fix for this instead of patching and patching?
added sortOrder ios property to version 0.27.0
@ivpusic is the iPhone XS/XR fix also for the new pictures first on the list? Because after installing the 0.27.0, doing pod install i keep seeing the "wrong" if in the QBAssetViewController.m that is causing this glitch. I will test it out and let you know, tho. Thanks in advance.
// Scroll to bottom
if (self.fetchResult.count > 0 && self.isMovingToParentViewController && !self.disableScrollToBottom
EDIT: Arghh, i'm on RN 0.60.6 and it throws "'React/RCTImageURLLoader.h' not found", i have to downgrade to 0.25, but 0.25 won't have this fix. How can i solve this? :(
Most helpful comment
This is just a temporary solution if you don't want to update
react-nativeandreact-native-image-crop-picker version.Open file:
ios/Pods/QBImagePickerController/QBImagePicker/QBAssetsViewController.mSearch this line:
Insert this line above it:
This is result