2013-08-29 8 views

risposta

17

È necessario aggiungere un ALAssetsFilter al gruppo durante l'enumerazione. Ecco un esempio di base:

ALAssetsLibrary* library = [[ALAssetsLibrary alloc] init]; 

[library enumerateGroupsWithTypes:ALAssetsGroupAll usingBlock:^(ALAssetsGroup *group, BOOL *stop) { 
    if (group) { 
     [group setAssetsFilter:[ALAssetsFilter allVideos]]; 
     [group enumerateAssetsUsingBlock:^(ALAsset *asset, NSUInteger index, BOOL *stop){ 
      if (asset){ 

       NSDictionary *meta = [[asset defaultRepresentation] metadata]; 

      } 
     }]; 
    } 
} failureBlock:^(NSError *error) { 
    NSLog(@"error enumerating AssetLibrary groups %@\n", error); 
}]; 

Per riferimento futuro, il available filters sono:

- allPhotos 
- allVideos 
- allAssets 
+0

nota che in base ai documenti [] (https://developer.apple.com/library/ios/documentation /AssetsLibrary/Reference/ALAssetsLibrary_Class/Reference/Reference.html#//apple_ref/doc/constant_group/Types_of_Asset) 'ALAssetsGroupAll' è" uguale a ORing insieme a tutti i tipi di gruppo ad eccezione di 'ALAssetsGroupLibrary'". Se vuoi anche iTunes, usa 'ALAssetsGroupAll | ALAssetsGroupLibrary' che "include tutte le risorse sincronizzate da iTunes". – bcattle

Problemi correlati