保存 UIImagePicker 视频 [英] Save an UIImagePicker Video

查看:63
本文介绍了保存 UIImagePicker 视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经搜索和搜索但找不到基本的 UIImagepicker 视频保存代码.我已经准备好了一切,只有一片空白.

I have searched and searched but can not find a basic UIImagepicker video save code. I have everything set up and just have a blank void.

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

我知道这与字典有关,但在那之后我迷路了,有什么帮助吗?

I know it has something to do with the dictionary, but after that I'm lost, any help?

推荐答案

试试这个代码,将视频保存到相册.

Try this code for save the video on photo album.

    - (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);
    }

这篇关于保存 UIImagePicker 视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆