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