【问题标题】:Fetch images from iCloud Photo Library PHImageManager从 iCloud 照片库 PHImageManager 获取图像
【发布时间】:2017-11-20 13:45:53
【问题描述】:


我目前遇到一个问题,即使用 iCloud 照片库并选择未本地保存的图像的用户,PHImageManager 返回空白图像(无)。
是否有自动下载仅存储在 iCloud 中的图像的特定选项?
(我使用自定义的 CollectionView 和 PHImageManager)

【问题讨论】:

    标签: ios swift4 photos


    【解决方案1】:

    您可以使用“requestImageData”从 iCloud 下载图像:

    斯威夫特 4:

    let manager = PHImageManager.default()
    let requestOptions = PHImageRequestOptions()
    requestOptions.resizeMode = .exact
    requestOptions.deliveryMode = .highQualityFormat;
    
    // Request Image
    manager.requestImageData(for: asset, options: requestOptions, resultHandler: { (data, str, orientation, info) -> Void in
        // Do somethign with Image Data
    })
    

    如果您已经在使用它来下载图像,看起来您需要这个选项来从 iCloud 下载它:PHImageRequestOptions.isNetworkAccessAllowed

    有关更多信息,您可以访问我找到的以下链接: PHImageManager requestImageData with Photos iCloud Photo Library

    【讨论】:

      【解决方案2】:

      如果您在通过 PHImageManager 从 iCloud 获取图像时遇到问题,除了设置 PHImageRequestOptions.isNetworkAccessAllowed 之外,请确保您没有通过 Charles Proxy 进行连接,iCloud 出于某种原因不喜欢这样...

      【讨论】:

        猜你喜欢
        • 2016-11-22
        • 1970-01-01
        • 2015-09-11
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-11-08
        • 1970-01-01
        相关资源
        最近更新 更多