PHFetchResult-照片排序

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];

你可能感兴趣的:(PHFetchResult-照片排序)