How to loop through a photo gallery in swift with photos framework

后端 未结 2 1317
鱼传尺愫
鱼传尺愫 2020-12-29 14:09

I have an app that creates a unique photo gallery for each ticket on my app. I need to figure out how to loop through that gallery so I can upload the images to the server o

2条回答
  •  半阙折子戏
    2020-12-29 14:50

    func fetchVideoFromLibrary() {
           let fetchOptions: PHFetchOptions = PHFetchOptions()
           fetchOptions.sortDescriptors = [NSSortDescriptor(key: "creationDate", ascending: false)]
           let fetchResult = PHAsset.fetchAssetsWithMediaType(.Video, options: fetchOptions)
           fetchResult.enumerateObjectsUsingBlock { (object, index, stop) -> Void in
               let options = PHImageRequestOptions()
               options.synchronous = true
               options.deliveryMode = .HighQualityFormat
               PHImageManager.defaultManager().requestAVAssetForVideo(object as! PHAsset, options: .None) { (avAsset, avAudioMix, dict) -> Void in
                   print(avAsset)
               }
           }
       }
    

提交回复
热议问题