self.m_library = [[ALAssetsLibraryalloc] init];
然后设置
NSUInteger type = ALAssetsGroupLibrary |ALAssetsGroupAlbum | ALAssetsGroupEvent |
ALAssetsGroupFaces | ALAssetsGroupPhotoStream;
self.m_assetsFilter = [ALAssetsFilterallPhotos];
下面写一些的回调函数块
ALAssetsLibraryGroupsEnumerationResultsBlock resultsBlock = ^(ALAssetsGroup *group,BOOL *stop)
{//获取块信息,就是分组的信息
if (group)
{
[group setAssetsFilter:self.m_assetsFilter];
if (group.numberOfAssets >0)
{
temp.m_ALAssetsGroup = group;
[self.m_groupsArrayaddObject:temp];
}
}
else
{
[self.m_contentCollectViewreloadData];
}
};
ALAssetsLibraryAccessFailureBlock failureBlock = ^(NSError *error)
{
NSLog(@"failure");
};
[self.m_libraryenumerateGroupsWithTypes:ALAssetsGroupSavedPhotos
usingBlock:resultsBlock
failureBlock:failureBlock];
[self.m_libraryenumerateGroupsWithTypes:type
usingBlock:resultsBlock
failureBlock:failureBlock];
下面是获取每一组的里面ALAsset的
ALAssetsGroupEnumerationResultsBlock resultsBlock = ^(ALAsset *asset,NSUInteger index, BOOL *stop) {
if (asset)
{
NSString *type = [asset valueForProperty:ALAssetPropertyType];
if ([type isEqual:ALAssetTypePhoto])
{
}
}
else if (self.m_subArray.count >0)
{
[self performSelectorOnMainThread:@selector(reloadSubData:)withObject:m_indexPath waitUntilDone:NO];
}
};
[assetsGroup enumerateAssetsUsingBlock:resultsBlock];
这样每一组的里面的内容都展示出来
还有可以参考
CTAssetsPickerController第三方的代码