iPhone:照片框架:如何只获取由我的应用程序创建的专辑/图像而不是其他人? [英] iPhone : Photos framework : how to get only those album/images which created by my app only not by others?

查看:156
本文介绍了iPhone:照片框架:如何只获取由我的应用程序创建的专辑/图像而不是其他人?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个像照片应用程序的应用程序。我的应用程序创建相册并捕获图像并将其保存在照片应用中的相册中。为此,我使用的是Photos框架。当我提取相册时,它会为我提供由我的应用以及其他应用创建的相册。所以我只想要我的应用程序创建的专辑/图像,而不是其他应用程序。

I am creating a application like photos app. My application creates albums and captures images and saves them in albums in photos app. For this I am using Photos framework. When i am fetching albums it gives me albums which created by my app as well as other apps. So I want only those album/images which created by my app only not by other apps.

推荐答案

没有直接的方法可以做到这一点。但这是一种解决方法。

There is no straight-forward way to do this. But this is a workaround.

PHFetchResult *topLevelUserCollections = [PHCollectionList fetchTopLevelUserCollectionsWithOptions:nil];
    self.collectionsFetchResults = @[topLevelUserCollections];

    for (PHFetchResult *fetchResult in self.collectionsFetchResults) {
            for (PHAssetCollection *assetCollection in fetchResult) {
                BOOL shouldShowCollection = NO;
                if ([assetCollection.localizedTitle isEqualToString:@"YOUR_APP_NAME"]) {
                    shouldShowCollection = YES;
                }

                if (shouldShowCollection) {
                   //collectionsToShow are the collections that you will show up in your table view
                   [self.collectionsToShow addObject:assetCollection];
                }
            }
        }

这篇关于iPhone:照片框架:如何只获取由我的应用程序创建的专辑/图像而不是其他人?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆