将视频保存到照片库 - iPhone SDK

lab*_*b12 4 iphone video xcode photo objective-c

有什么办法可以将Documents目录中的视频保存到照片库吗?我在文档目录中有视频的链接,我只是不知道如何将其保存到Photos应用程序.

谢谢,

凯文

Gok*_*kul 6

如果首先将其保存在本地目录中,则可以将其另存为..

    ALAssetsLibrary *assetLibrary = [[ALAssetsLibrary alloc] init];
    [assetLibrary writeVideoAtPathToSavedPhotosAlbum:url completionBlock:^(NSURL *assetURL, NSError *error){
        if(error) {
           NSLog(@"error while saving to camera roll %@",[error localizedDescription]);        
        } else {
            //For removing the back up copy from the documents directory           
            NSError *removeError = nil;
            [[NSFileManager defaultManager] removeItemAtURL:url error:&removeError];
            NSLog(@"%@",[removeError localizedDescription]);
        }
    }];
Run Code Online (Sandbox Code Playgroud)