Photokit preserve user album list order
NickName:klcjr89 Ask DateTime:2015-06-11T10:16:07

Photokit preserve user album list order

Is there any way to preserve the list order a user has arranged all of their albums in the Photos app? I've been trying to fix this all day, and I can't seem to figure out what I'm missing to preserve the order for displaying in my app.

I would like to preserve the order because a user can rearrange their albums in the Photos app, so I want my UI to match the list order.

Code I'm using to set up the list:

PHFetchResult *smartAlbumFetchResult = [PHAssetCollection fetchAssetCollectionsWithType:
PHAssetCollectionTypeSmartAlbum subtype:PHAssetCollectionSubtypeAny options:nil];

PHFetchResult *albumFetchResult = [PHAssetCollection fetchAssetCollectionsWithType:
PHAssetCollectionTypeAlbum subtype:PHAssetCollectionSubtypeAny options:nil];

NSArray *collectionFetches = @[smartAlbumFetchResult, albumFetchResult];

NSMutableArray *albumArray = [NSMutableArray new];

for (PHFetchResult *newFetch in collectionFetches)
{
    for (PHAssetCollection *sub in newFetch)
    {
        [albumArray addObject:sub];
         // Other setup omitted
    }
}

Copyright Notice:Content Author:「klcjr89」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/30770453/photokit-preserve-user-album-list-order

Answers
asclepix 2015-06-19T21:50:23

Sorry, but I don't think it's possible actually (I hope in some upgrades).\nIn fact, it is possible to use PHFetchOptions to sort asset collections, but PhotoKit supports only a restricted set of keys for the predicate and sortDescriptors properties (see PHFetchOptions) and between these I can't see a key for the the list order a user has arranged in the Photos app.",


More about “Photokit preserve user album list order” related questions

Photokit preserve user album list order

Is there any way to preserve the list order a user has arranged all of their albums in the Photos app? I've been trying to fix this all day, and I can't seem to figure out what I'm missing to prese...

Show Detail

Creating Subfolder inside a folder using PhotoKit

I understand how one can create a folder programmatically using Apple's PhotoKit API and add Photos to the folder. PHPhotoLibrary.shared().performChanges({ let req =

Show Detail

Apple PhotoKit API - access to faces/people

Currently does the PhotoKit API allow access to the People album & the face information or is all that private? For example is it possible to fetch all of the photos of "John Smith" if I have...

Show Detail

Get photos that contains disparity data in iOS11 from PhotoKit

I want to get the user photos that contains disparity data, my first thought was to use the smart album .smartAlbumDepthEffect but since Portrait Mode photos taken in iOS 10 doesn't have disparity ...

Show Detail

How to delete an Album on iOS?

I'm using PhotoKit and I've created an album PHAssetCollectionChangeRequest.creationRequestForAssetCollection(withTitle: RooPhotoAlbum.albumName) But I found some issue with first time saving fi...

Show Detail

ios 8, how to get all photos using ALAssetLibrary to replace the missing camera roll album

I have an app that has a custom Image Picker that uses the ALAssetLibrary to create an Album picker and image picker. We've implemented a custom picker in order for our customers to select multiple

Show Detail

Cannot get a clear image requested from Photo Album using PhotoKit

I am using PhotoKit to fetch the photos in one of the system albums like this: PHFetchOptions *fetchOptions = [[PHFetchOptions alloc] init]; fetchOptions.sortDescriptors = @[[NSSortDescriptor

Show Detail

MacOS PhotoKit - List all user-created Smart Albums?

I've started playing around with macOS development for the first time. I'm trying to query the list of Smart Albums I've created in the macOS Photos app. As you can see in this screenshot, I've d...

Show Detail

iOS8 PhotoKit, some albums can't be finded

When I used PhotoKit to create my albums,there is not all albums in my project,some albums imported from computer can't be searched.I will post my code follow. //get system albums PHImageRequestOp...

Show Detail

iOS Images, photokit, image orientation

I am working on an iOS app using iOS 8 and the new PhotoKit, I iterate over user images and I am trying to find out via code whether an image is vertical or horizontal? is there a flag I can inspec...

Show Detail