The AssetsLibrary framework provides the ALAssetsLibrary class to help us access the photos and videos managed by the album program. See this for official documentation.
If (! Self. assetsLibrary ){
_ AssetsLibrary = [[ALAssetsLibrary alloc] init];
}
Through this framework, we can get the album list:
[_ AssetsLibrary enumerateGroupsWithTypes: ALAssetsGroupAll usingBlock: ^ (ALAssetsGroup * group, BOOL * stop ){
If (group ){
[Self. groupArray addObject: group];
}
} FailureBlock: ^ (NSError * error ){
NSLog (@ "Group not found! N ");
}];
By clicking on each album, we can access the photo list in the album:
# Pragma mark-
-(Void) getImages
{
If (! Self. assetsArray ){
_ AssetsArray = [[NSMutableArray alloc] init];
}
If (! Self. assetsLibrary ){
_ AssetsLibrary = [[ALAssetsLibrary alloc] init];
}
@ Autoreleasepool {
[Self. assetsGroup enumerateAssetsUsingBlock: ^ (ALAsset * result, NSUInteger index, BOOL * stop ){
If (result ){
TTAsset * ttAsset = [[TTAsset alloc] initWithAsset: result];
[Self. assetsArray addObject: ttAsset];
[TtAsset release], ttAsset = nil;
}
}];
}
[Self. tableView reloadData];
}
Finally, we can customize the display style through the custom Cell, such as the selected effect and the selected list at the bottom.