【问题标题】:Getting all assets of imagePaths获取 imagePaths 的所有资产
【发布时间】:2019-05-02 03:39:18
【问题描述】:

我有一个 imagePaths 列表,我想用它来获取 PHassets。我正在考虑使用fetchAssets(withALAssetURLs:options:),但事实证明它已被弃用。还有其他方法吗?

【问题讨论】:

    标签: ios swift phasset photosframework


    【解决方案1】:

    AssetURLs 不是 imagePaths,它们是将弃用的 ALAssets 映射到较新的 PHAssets 的唯一 URL,但不代表物理文件位置。

    Photos 框架中没有处理图像路径的方法是有充分理由的。 iOS 照片库中照片/视频的文件位置是私有的和沙盒的。您不能直接从您的应用程序访问这些图像路径。只有部分 Photos 框架方法内部使用图片路径,可以通过设置安全范围临时访问文件。

    【讨论】:

      【解决方案2】:

      事实证明我并不真的需要 imagePaths。我只需要使用 localIdentifier (https://developer.apple.com/documentation/photokit/phobject/1622400-localidentifier) 并使用 https://developer.apple.com/documentation/photokit/phasset/1624732-fetchassets。谢谢。

      【讨论】:

        猜你喜欢
        • 2017-02-19
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-03-07
        • 2020-09-28
        相关资源
        最近更新 更多