将视频保存到特定文件夹

3

我正在使用以下代码将视频保存到我的照片库中:

    ALAssetsLibrary *assetLibrary = [[ALAssetsLibrary alloc] init];
    [assetLibrary writeVideoAtPathToSavedPhotosAlbum:[NSURL URLWithString:videoPath] completionBlock:^(NSURL *assetURL, NSError *error)
    {
         NSError *removeError = nil;
         [[NSFileManager defaultManager] removeItemAtURL:[NSURL URLWithString:videoPath] error:&removeError];
    });

视频将会被保存在文件夹视频中,但我希望它能够被保存在一个特定的文件夹中,这个文件夹的名字与应用程序相同。我该如何实现这一点?

然后你需要保存在沙盒中。 - falcon143
尝试在块内执行 [self addAssetURL:pathUrl toAlbum:folderName withCompletionBlock:completionBlock]; - falcon143
哪里?之后?里面? - bruno
以下答案是否有效 - falcon143
不行,它有错误,我还在修复中。 - bruno
1个回答

0

像这样

 ALAssetsLibrary* assetLibrary = [[ALAssetsLibrary alloc] init];
 [assetLibrary writeVideoAtPathToSavedPhotosAlbum:[NSURL URLWithString:@""] completionBlock:^(NSURL *assetURL, NSError *error) {
    [assetLibrary addAssetURL:[NSURL URLWithString:@""]  toAlbum:@"" completion:^(NSURL *assetURL, NSError *error) {
    NSError* removeError = nil;
        [[NSFileManager defaultManager] removeItemAtURL:[NSURL URLWithString:@""] error:&removeError];
    } failure:^(NSError *error) {
        NSLog(@"%@", error);
    }];
}];

尝试一下这个:http://stackoverflow.com/questions/10721988/save-video-to-custom-album-in-camera-roll?rq=1 - falcon143
让我问一个问题,哪个更愚蠢,上面的代码还是URL? - falcon143
更改上面评论中的代码,将pathUrl替换为assetURL,我会接受你的答案。 - bruno
[self addAssetURL...] 不存在,请像我已经说的那样将其更改为 [assetLibrary addAssetURL...]。 - bruno
让我们在聊天中继续这个讨论 - falcon143
显示剩余4条评论

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接