根据我的理解,连拍模式的照片将一个接一个地添加到库中。每张图片的
ALAssetProperty
类型将是
ALAssetTypePhoto
。因此,您可以使用以下ALAsset块单独获取每张照片。由于仅有7种
ALAssetsGroupTypes
和3种
ALAssetsFilters
可用,因此您无法一次检索仅限于连拍模式照片的集合。其中没有任何与连拍模式照片相关的内容。我希望Apple将来会提供连拍照片过滤功能。
---------------------------- ALAssetsGroupType -------------------------------------------
ALAssetsGroupLibrary // The Library group that includes all assets.
ALAssetsGroupAlbum // All the albums synced from iTunes or created on the device.
ALAssetsGroupEvent // All the events synced from iTunes.
ALAssetsGroupFaces // All the faces albums synced from iTunes.
ALAssetsGroupSavedPhotos // The Saved Photos album.
ALAssetsGroupPhotoStream // The PhotoStream album.
ALAssetsGroupAll // The same as ORing together all the available group types,with the exception that ALAssetsGroupLibrary is not included.
-------------------------- ALAssetsFilter ------------------------------------------------
+ (ALAssetsFilter *)allPhotos; // Get all photos assets in the assets group.
+ (ALAssetsFilter *)allVideos; // Get all video assets in the assets group.
+ (ALAssetsFilter *)allAssets; // Get all assets in the group.
使用以下代码单独获取每张照片,包括连拍模式的照片:
- (void)findBurstModePhotos
{
ALAssetsLibrary *assetLibrary = [ViewController defaultAssetsLibrary];
[assetLibrary enumerateGroupsWithTypes:ALAssetsGroupAll usingBlock:^(ALAssetsGroup *group, BOOL *stop)
{
[group enumerateAssetsUsingBlock:^(ALAsset *result, NSUInteger index, BOOL *stop) {
if(result)
{
[self evaluateGroup:group];
}
}];
} failureBlock:^(NSError *error) {
NSLog(@"Error loading images %@", error);
}];
}
- (void)evaluateGroup:(ALAssetsGroup *)group
{
[group enumerateAssetsUsingBlock:^(ALAsset *result,
NSUInteger index,
BOOL *stop) {
NSLog(@"Photo date: %@", [result valueForProperty:ALAssetPropertyDate]);
}];
}
+ (ALAssetsLibrary *)defaultAssetsLibrary
{
static dispatch_once_t pred = 0;
static ALAssetsLibrary *library = nil;
dispatch_once(&pred, ^{
library = [[ALAssetsLibrary alloc] init];
});
return library;
}
输出日志:
Photo date: 2013-05-06 15:57:21 +0000 //non burst image.
Photo date: 2013-05-06 15:57:41 +0000 //non burst image.
Photo date: 2013-12-20 21:10:40 +0000 //burst image.
Photo date: 2013-12-20 21:10:41 +0000 //burst image.
Photo date: 2013-12-20 21:10:41 +0000 //burst image.
Photo date: 2013-12-20 21:10:41 +0000 //burst image.
Photo date: 2013-12-20 21:10:41 +0000 //burst image.
Photo date: 2013-12-20 21:10:42 +0000 //burst image.
Photo date: 2013-12-20 21:10:42 +0000 //burst image.
Photo date: 2013-12-20 21:10:42 +0000 //burst image.
Photo date: 2013-12-20 21:10:43 +0000 //burst image.
Photo date: 2013-12-20 21:10:43 +0000 //burst image.
Photo date: 2013-12-20 21:10:43 +0000 //burst image.
Photo date: 2013-12-20 21:10:44 +0000 //burst image.
Photo date: 2013-12-20 21:10:44 +0000 //burst image.
Photo date: 2013-12-20 21:10:44 +0000 //burst image.
Photo date: 2013-12-20 21:10:44 +0000 //burst image.
Photo date: 2013-12-20 21:10:45 +0000 //burst image.
Photo date: 2013-12-20 21:10:45 +0000 //burst image.
Photo date: 2013-12-20 21:10:45 +0000 //burst image.
Photo date: 2013-12-20 21:10:45 +0000 //burst image.
Photo date: 2013-12-20 21:10:46 +0000 //burst image.
注意:
如果连拍模式照片捕获相机是您的应用程序的一部分,则在将捕获的照片保存到照片库时,请存储ALAsset URL
。您可以通过ALAsset
库使用保存的ALAsset URL
检索此照片。
ALAssetPropertyType
时,它是否报告为ALAssetTypePhoto
?我之所以问是因为我想知道是否有新的ALAssetType,他们还没有记录(在API尚未完全实现这些类型的情况下)。 - AndrewPKALAssetPropertyURLs
的内容以获取可用的连拍收藏? - WainALAssetPropertyURLs
的值,但它只返回一个URL,用于在iPhone 5s上拍摄的连拍模式照片。 - Jeff Kelley