custom bar ios alassetslibrary alasset alassetsgroup

ios - custom view navigation bar swift



Accede a las fotos del modo Burst en la biblioteca (1)

Estoy tratando de acceder a las fotos en la biblioteca de activos de iOS que el usuario ha tomado usando el modo Ráfaga. Estoy tratando de usar ALAssetsLibrary y filtrar fotos:

- (void)findBurstModePhotos { ALAssetsFilter *allPhotos = [ALAssetsFilter allPhotos]; ALAssetsLibrary *assetLibrary = [[ALAssetsLibrary alloc] init]; [assetLibrary enumerateGroupsWithTypes:ALAssetsGroupAll usingBlock:^(ALAssetsGroup *group, BOOL *stop) { [group setAssetsFilter:allPhotos]; NSLog(@"Group: %@", [group valueForProperty: ALAssetsGroupPropertyName]); if ([group numberOfAssets] > 0) { [self evaluateGroup:group]; } } failureBlock:^(NSError *error) { NSLog(@"Failure enumerating groups: %@", [error localizedDescription]); }]; } - (void)evaluateGroup:(ALAssetsGroup *)group { [group enumerateAssetsUsingBlock:^(ALAsset *result, NSUInteger index, BOOL *stop) { NSLog(@"Photo date: %@", [result valueForProperty:ALAssetPropertyDate]); }]; }

Desafortunadamente, esto devuelve las fotos del modo de ráfaga como una sola foto. ¿Hay una forma compatible de obtener fotos del modo de ráfaga individualmente? Me gustaría obtener cada foto de una sola sesión en modo Burst.


Según mis conocimientos, las fotos del modo de ráfaga se agregarán a la biblioteca una por una. ALAssetProperty tipo ALAssetProperty de cada imagen será ALAssetTypePhoto . Por lo tanto, puede obtener cada foto por separado utilizando el bloque ALAsset a continuación. No puedes recuperar solo el conjunto de fotos del modo de ráfaga a la vez porque solo hay 7 tipos de ALAssetsGroupTypes y 3 tipos de ALAssetsFilters están disponibles. Ninguno de ellos está tratando con fotos de modo ráfaga.

Espero que Apple proporcione el filtro de fotos Burst en el futuro.

---------------------------- 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.

Use el siguiente código para obtener cada foto por separado, incluidas las fotos del modo de ráfaga

- (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; }

Registro de salida:

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.

Nota:

Si la cámara de captura de fotos del modo de ráfaga forma parte de su aplicación, almacene las ALAsset URL''s cuando guarde las fotos capturadas en la galería de fotos. Puede recuperar esta foto utilizando las ALAsset URL''s guardadas a través de la biblioteca ALAsset .