0

我在我的应用程序中创建了三个 PHCollections。在我的应用程序的不同部分,我试图获取它们并将它们显示在表格视图中。我可以使用以下代码获取所有用户创建的库

    let topLevelUserCollections: PHFetchResult  = PHCollectionList.fetchTopLevelUserCollectionsWithOptions(nil)
    self.collectionsFetchResults = [topLevelUserCollections];
    self.collectionsLocalizedTitles = ["My Clips"];
    PHPhotoLibrary.sharedPhotoLibrary().registerChangeObserver(self) //With this you need to conform to PHPhotoLibraryChangeObserver

但是我怎样才能只获取我想要的资产集合呢?另外,我只想要视频而不是图像,有没有办法只获取视频资产的结果?

4

1 回答 1

0

PHCollectionList.fetchTopLevelUserCollectionsWithOptions使用 nil 参数调用。但是那个 nil 是 PHFetchOptions。这些 PHFetchOptions 正是您制定此类规范的方式。

特别是,如果您自己创建了这些集合,那么您就有了它们的localIdentifier价值。这正是您在 PHFetchOptions 中指定predicate以提取这些集合的内容。你也可以通过localizedTitle等等来做。

于 2014-11-29T02:49:08.710 回答