我认为AssetLibrary的群组(专辑)枚举api不再适用于ios 8.02,enumerateGroupsWithTypes:usingBlock:在枚举所有群组时不返回最近添加的群组,并在调用时返回空图书馆组(记录为://包含所有资产的图书馆组。)
这是我的代码
+(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;
}
是否会发生在其他人身上?
答案 0 :(得分:1)
ALAssetsGroupLibrary:包含从iTunes同步的所有资源的“库”组。
这不是相机胶卷。不带摄像头的设备的相机胶卷或已保存照片应位于ALAssetsGroupSavedPhotos
。我认为他们已经从8.0.2中的Recently Added
恢复了它。