PHFetchResult-照片排序
2020-03-30 本文已影响0人
兔子吃啥
PHAssetCollection *collection = (PHAssetCollection *)result;
PHFetchOptions*options = [[PHFetchOptionsalloc]init];
options.predicate = [NSPredicate predicateWithFormat:@"mediaType = %d OR mediaType = %d",PHAssetMediaTypeImage, PHAssetMediaTypeVideo];
NSSortDescriptor *sort = [NSSortDescriptor sortDescriptorWithKey:@"creationDate" ascending:NO];
//ascending为NO,即为逆序(由现在到过去), ascending为YES时即为默认排序,由远到近
options.sortDescriptors=@[sort];
PHFetchResult*assetsFetchResult =[PHAssetfetchAssetsInAssetCollection:collectionoptions:options];