保存UIImagePicker拍摄的视频

3

我已经搜索了很多,但是找不到一个基本的UIImagepicker视频保存代码。我已经设置好了一切,但只得到一个空白的界面。

- (void)imagePickerController:(UIImagePickerController *)
         picker didFinishPickingMediaWithInfo:(NSDictionary *)
              info{
}

我知道这与字典有关,但之后我就迷失了,需要帮助吗?
1个回答

8

尝试使用以下代码将视频保存到相册。

    - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
    {
        [self dismissModalViewControllerAnimated:YES];

        //get the videoURL 
        NSString *tempFilePath = [[info objectForKey:UIImagePickerControllerMediaURL] path];

        if ( UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(tempFilePath))
        {
                // Copy it to the camera roll.
                UISaveVideoAtPathToSavedPhotosAlbum(tempFilePath, self, @selector(video:didFinishSavingWithError:contextInfo:), tempFilePath);
            } 
    }

    - (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {
        [self dismissModalViewControllerAnimated:YES];
    }

    - (void) video: (NSString *) videoPath
    didFinishSavingWithError: (NSError *) error
       contextInfo: (void *) contextInfo {
        NSLog(@"Finished saving video with error: %@", error);
    }

1
尽管我在使用桥接器作为最后一个参数时收到了有关工作的警告,就像这样:UISaveVideoAtPathToSavedPhotosAlbum(tempFilePath, self, @selector(video:didFinishSavingWithError:contextInfo:), (__bridge void *) tempFilePath); - elliotrock

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