我能够将图像保存到 iPhone 相机滚动中的自定义相册中。 例如, 相册名称可以是“ Fun ”, 我拍摄的所有图像都会放入该文件夹。 我遇到了一个帮手班< a href=' http://www.touch- code-magazine.com/ ios5- savec- photos- in- custom- photo- album- 类以下载/ “ rel=“ no follown” >, 这里非常适合完成我想要完成的任务 。
然而,我所使用的方法并没有将视频保存到自定义文件夹中,但是创建了文件夹 - 它只是空的视频, 我试图保存在那里。 我尝试了调试它, 但没有进展。 这个方法在这里 :
-(void)addAssetURL:(NSURL*)assetURL toAlbum:(NSString*)albumName withCompletionBlock:(SaveImageCompletion)completionBlock
{
__block BOOL albumWasFound = NO;
//search all photo albums in the library
[self enumerateGroupsWithTypes:ALAssetsGroupAlbum
usingBlock:^(ALAssetsGroup *group, BOOL *stop) {
//compare the names of the albums
if ([albumName compare: [group valueForProperty:ALAssetsGroupPropertyName]]==NSOrderedSame) {
//target album is found
albumWasFound = YES;
NSData *data = [NSData dataWithContentsOfURL:assetURL];
if ([data length] > 0) {
//get a hold of the photo s asset instance
[self assetForURL: assetURL
resultBlock:^(ALAsset *asset) {
[group addAsset: asset];
//run the completion block
completionBlock(nil);
} failureBlock: completionBlock];
}
//album was found, bail out of the method
return;
}
if (group==nil && albumWasFound==NO) {
//photo albums are over, target album does not exist, thus create it
__weak ALAssetsLibrary* weakSelf = self;
//create new assets album
[self addAssetsGroupAlbumWithName:albumName
resultBlock:^(ALAssetsGroup *group) {
//get the photo s instance
[weakSelf assetForURL: assetURL
resultBlock:^(ALAsset *asset) {
NSLog(@"asset: %@",asset);
//add photo to the newly created album
[group addAsset: asset];
//call the completion block
completionBlock(nil);
} failureBlock: completionBlock];
} failureBlock: completionBlock];
//should be the last iteration anyway, but just in case
return;
}
} failureBlock: completionBlock];
}
有没有人知道 将视频保存到照片馆的自定义专辑里 的适当方式?