Save an UIImagePicker Video

自古美人都是妖i 提交于 2019-12-10 20:38:20

问题


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?


回答1:


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


来源:https://stackoverflow.com/questions/6287413/save-an-uiimagepicker-video

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!