【问题标题】:How to list Shared Photo Stream Albums with PhotoKit如何使用 PhotoKit 列出共享的照片流相册
【发布时间】:2014-09-21 07:25:13
【问题描述】:

我可以通过PHFetchResult *results = [PHCollectionList fetchTopLevelUserCollectionsWithOptions:nil];获取在设备上创建的相册列表

我想一定有类似的方法来获取共享照片流相册(或者我认为它们现在可能被称为“iCloud 照片共享相册”),但对于我的生活......无法弄清楚.有人解决了这个问题吗?

【问题讨论】:

    标签: ios ios8 icloud photokit


    【解决方案1】:

    PhotoKit 的查询逻辑让我很困惑,但下面的答案对我有用(提示:您必须查询 PHAssetCollection,而不是 PHCollectionList

    PHFetchResult *results = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeAlbum subtype:PHAssetCollectionSubtypeAlbumCloudShared options:nil]

    【讨论】:

    • 我可以获取共享此相册的 cloudOwner 名称吗?
    【解决方案2】:

    对于那些寻求快速语法的人:

    let result = PHAssetCollection.fetchAssetCollections(with: PHAssetCollectionType.album, subtype: PHAssetCollectionSubtype.albumCloudShared, options: nil)
    
    result.enumerateObjects { (phassetcollection, index, setThisToTrueToStop) in
        print("\(index): \(phassetcollection.localizedTitle)  \(phassetcollection.localIdentifier)")
    }
    

    【讨论】:

    • 最近的 Swift 语法:let result = PHAssetCollection.fetchAssetCollections(with: PHAssetCollectionType.album, subtype: PHAssetCollectionSubtype.albumCloudShared, options: nil); result.enumerateObjects { (phassetcollection, index, setThisToTrueToStop) in }
    • @otusweb 我可以获取共享此相册的 cloudOwner 名称吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-11-26
    • 1970-01-01
    • 2013-08-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多