如何知道PHAssetCollection是否是最近删除的集合? [英] How to know if an PHAssetCollection is the recently deleted collection?
问题描述
最近添加的集合有一个子类型: PHAssetCollectionSubtypeSmartAlbumRecentlyAdded
。但是没有可以识别最近删除集合的
assetCollectionSubtype
。
最近删除的资源CollectionCollectionType = 2/2。最近删除的资源集合类型= 2 / 1000000201
这表示类型为 PHAssetCollectionTypeSmartAlbum
。但是什么是子类型 1000000201
?
201
应根据文档 PHAssetCollectionSubtypeSmartAlbumPanoramas
。
魔法数字 1000000201
被信任从不改变?
但是,这是您如何检索最近删除的集合:
PHFetchResult * smartAlbums = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeSmartAlbum subtype:1000000201 options:nil];
这个特别的智能相册有一个主要区别: PHAsset
s不能删除(再次),因为这是垃圾桶。因此,必须知道是否应向用户提供删除选项。
有没有人有想法?
<$ c> 关于选择最近删除的集合, $ c> PHFetchResult * smartAlbums = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeSmartAlbum
subtype:PHAssetCollectionSubtypeAlbumRegular
options:nil];
__block PHAssetCollection * recentlyDeletedCollection;
[smartAlbums enumerateObjectsUsingBlock:^(PHAssetCollection * smartAlbum,NSUInteger idx,BOOL * stop){
if([smartAlbum.localizedTitle isEqualToString:@Recently Deleted]){
NSLog最近删除的相簿位于%ld,idx);
recentlyDeletedCollection = smartAlbums [idx];
}
}];
There is a subtype for the recently added collection: PHAssetCollectionSubtypeSmartAlbumRecentlyAdded
. However there is no
assetCollectionSubtype
that would identify the "Recently Deleted" collection.
This is the description of the "Recently Deleted" collection in my case:
(iOS 8.1.3): DF876BFD-...-C97F4628467C/L0/040 Recently Deleted assetCollectionType=2/1000000201
This indicates it is of type PHAssetCollectionTypeSmartAlbum
. But what the heck is subtype 1000000201
?
201
should be PHAssetCollectionSubtypeSmartAlbumPanoramas
according to the docs.
Can the magic number 1000000201
be trusted to never change? Probably not.
However, this is how you can retrieve the recently deleted collection:
PHFetchResult *smartAlbums = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeSmartAlbum subtype:1000000201 options:nil];
There is a major difference in this particular smart album: the PHAsset
s can not be deleted (again), because this is the trash. So it'd be essential to know if a delete option should be presented to the user.
Does anyone have an idea?
Regarding picking out the "Recently Deleted" collection, here's a workaround.
PHFetchResult *smartAlbums = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeSmartAlbum
subtype:PHAssetCollectionSubtypeAlbumRegular
options:nil];
__block PHAssetCollection *recentlyDeletedCollection;
[smartAlbums enumerateObjectsUsingBlock:^(PHAssetCollection *smartAlbum, NSUInteger idx, BOOL *stop) {
if ([smartAlbum.localizedTitle isEqualToString:@"Recently Deleted"]) {
NSLog(@"Recently Deleted album is at %ld", idx);
recentlyDeletedCollection = smartAlbums[idx];
}
}];
这篇关于如何知道PHAssetCollection是否是最近删除的集合?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!