Is there a way to get the picture after giving the option on swift?

Asked 2 years ago, Updated 2 years ago, 30 views

Is there a way to specify a photo option (photo size, date, etc.) and bring the photos that fit that option?

swift ios

2022-09-22 21:39

1 Answers

Bring your PHAsset with you.

I think you can bring the information and compare it and then bring the pictures :)

import Photos

override func viewDidLoad() {

    let options = PHFetchOptions()
    options.predicate = NSPredicate(format: "mediaType = %d",PHAssetMediaType.Image.rawValue)
    options.sortDescriptors = [ NSSortDescriptor(key: "creationDate", ascending: true) ]
    let result : PHFetchResult = PHAsset.fetchAssetsWithOptions(options)

    for i in 0 ..< assetsFetchResults.count {
         let asset = assetsFetchResults[i] as! PHAsset        

        print("date = \(asset.creationDate!)")
        print("location = \(asset.location)")
        print("width = \(asset.pixelWidth), height=\(asset.pixelHeight))
    }

}


2022-09-22 21:39

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.