if (!self.assetsLibrary) {
_assetsLibrary = [[ALAssetsLibrary alloc] init];
}
通過該框架,我們可以獲取相冊列表:
[_assetsLibrary enumerateGroupsWithTypes:ALAssetsGroupAll usingBlock:^(ALAssetsGroup *group, BOOL *stop) {
if (group) {
[self.groupArray addObject:group];
}
} failureBlock:^(NSError *error) {
NSLog(@"Group not found!n");
}];
通過點擊每個相冊,我們可以訪問相冊裡的照片列表:
#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];
}
最後,我們可以通過自定義的Cell來定制展示風格,比如選中效果、底部選中列表等。