我认为 AssetLibrary 的 group(album) 枚举 api 在 ios 8.02 上不再起作用, enumerateGroupsWithTypes:usingBlock: 在枚举所有组时不返回最近添加的组,并且在调用 Library 组时返回空(记录为: // The Library包括所有资产的组。)
这是我的代码
+(void)loadCameraRollGroupFromAssetLibrary:(ALAssetsLibrary *)assetLibrary withBlock:(void (^)(BOOL hasPermission, YLCameraRollGroup *cameraRoll))block {
__block BOOL foundCameraRoll = NO;
[assetLibrary enumerateGroupsWithTypes:ALAssetsGroupLibrary usingBlock:^(ALAssetsGroup *assetsGroup, BOOL *stop) {
if(assetsGroup){
YLCameraRollGroup *group = [[YLCameraRollGroup alloc] initWithAssetsGroup:assetsGroup];
if(group.isCameraroll){
NSLog(@"found camera roll");
*stop = YES; // this fucking stop didn't work, don't know why
foundCameraRoll = YES;
block(YES, group);
return;
}
}
else{
if(!foundCameraRoll){
NSLog(@"no camera roll");
block(NO, nil);
}
}
} failureBlock:^(NSError *error) {
block(NO, nil);
}];
}
-(id)initWithAssetsGroup:(ALAssetsGroup *)assetsGroup{
self = [super init];
if(self){
self.name = [assetsGroup valueForProperty:ALAssetsGroupPropertyName];
NSLog(@"loaded group: %@", self.name);
self.assetsGroup = assetsGroup;
#if TARGET_IPHONE_SIMULATOR
self.isCameraroll = [self.name isEqualToString:@"Saved Photos"];
#else
self.isCameraroll = [self.name isEqualToString:@"Camera Roll"] || [self.name isEqualToString:@"Recently Added"];
#endif
}
return self;
}
它发生在其他人身上吗?