2013-03-22 15 views
7

I wyliczyć wszystkie grupy aktywów z zastosowaniem ALAssetsLibraryALAssetsLibrary dostać Camera Roll

Oto kod:

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

void (^enumerate)(ALAssetsGroup *, BOOL *) = ^(ALAssetsGroup *group, BOOL *stop) 
{ 
    if (group == nil) 
    { 
     // enumerated all albums.. 
    } 

    // I hot to check if group is Camera Roll ? 

}; 

[library enumerateGroupsWithTypes:ALAssetsGroupAll 
         usingBlock:enumerate 
        failureBlock:nil]; 

Jak sprawdzić, czy jakiś prąd wyliczeniowy jest CameraRoll?

Edytuj: Jak testowałem, zawsze był ostatni, używając tego wyliczenia. Ale nie jestem pewien, czy to jest zasada, czy są jakieś odniesienia, które przeoczyłem?

Odpowiedz

14

Aby uzyskać zdjęcia z rolki aparatu używać ALAssetsGroupSavedPhotos podczas wyliczania bibliotekę aktywa:

[library enumerateGroupsWithTypes:ALAssetsGroupSavedPhotos 
         usingBlock:enumerate 
        failureBlock:nil]; 

aby wykryć co grupa aktualnie dostać:

if ([[group valueForProperty:@"ALAssetsGroupPropertyType"] intValue] == ALAssetsGroupSavedPhotos) 
{ 
    NSLog(@"Camera roll"); 
} 
+0

widziałem o tym rozwiązaniu, ale muszę aby wiedzieć, która z wymienionych grup jest rolką aparatu, spójrz na kod –

+0

Dzięki, działało tak jak chciałem! :) –

3
imageArray = [[NSArray alloc] init]; 
    NSMutableArray*mutableArray =[[NSMutableArray alloc]init]; 

    NSMutableArray* assetURLDictionaries = [[NSMutableArray alloc] init]; 

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

void (^enumerate)(ALAssetsGroup *, BOOL *) = ^(ALAssetsGroup *group, BOOL *stop) 
{ 
    if ([[group valueForProperty:@"ALAssetsGroupPropertyType"] intValue] == ALAssetsGroupSavedPhotos) 
    { 
     NSLog(@"Camera roll"); 
     [group enumerateAssetsUsingBlock:^(ALAsset *result, NSUInteger index, BOOL *stop) { 
      ALAssetRepresentation *rep = [result defaultRepresentation]; 
      NSLog(@"Asset Name ----> %@",rep.filename); 


     }]; 
    } 
    // I hot to check if group is Camera Roll ? 

}; 

[library enumerateGroupsWithTypes:ALAssetsGroupSavedPhotos 
         usingBlock:enumerate 
        failureBlock:nil]; 
Powiązane problemy