Why did I call this method PHImageManager.default().requestImage, but the result I got was still false

16 Views Asked by At

I plan to get photos from iCloud, but after calling this method, the searched locallyAvailable is still false, but when I get videos, it always shows true. Why?

this is my method

public override func synciCloud(completionHandler: ((PhotoPickerPhoto, Bool) -> Void)?) {
        var version = PHImageRequestOptionsVersion.current
        let requestOptions = PHImageRequestOptions()
        requestOptions.isNetworkAccessAllowed = true
        requestOptions.deliveryMode = .highQualityFormat
        requestOptions.version = version
        requestOptions.resizeMode = .exact
        var asset = self.asset
        let localIdentifier = self.asset.localIdentifier
        PHImageManager.default().requestImage(for: asset, targetSize: PHImageManagerMaximumSize, contentMode: .aspectFit, options: requestOptions) { [weak self] (originImage, info) in
            guard let `self` = self else { return }
            if originImage == nil {
                print("123456no")
            }
            if let asset = PHAsset.fetchAssets(withLocalIdentifiers: [localIdentifier], options: nil).firstObject {
                var assetResource = PHAssetResource.assetResources(for: asset)
                if let v = assetResource.first?.value(forKey: "locallyAvailable") as? Bool {
                    print("123456" + "\(v)")#false
                    print("123456" + "\(assetResource.count)")# 1
                }
            }
            completionHandler?(self, true)
        }
}
0

There are 0 best solutions below