美文网首页
PHFetchResult-照片排序

PHFetchResult-照片排序

作者: 兔子吃啥 | 来源:发表于2020-03-30 10:31 被阅读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];

    相关文章

      网友评论

          本文标题:PHFetchResult-照片排序

          本文链接:https://www.haomeiwen.com/subject/xopmuhtx.html