如何将电影从相机胶卷复制/移动到应用程序自己的文档文件夹?
答案 0 :(得分:2)
您可以像这样实现您的委托方法imagePickerController:didFinishPickingMediaWithInfo:
-
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
NSURL * fileURL = [info objectForKey:UIImagePickerControllerMediaURL];
NSString * documentsDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString * storePath = [documentsDirectory stringByAppendingPathComponent:@"myMovie.MOV"];
NSError * error = nil;
[[NSFileManager defaultManager] copyItemAtURL:fileURL
toURL:[NSURL fileURLWithPath:storePath]
error:&error];
if ( error )
NSLog(@"%@", error);
[self dismissModalViewControllerAnimated:YES];
}
用户选择电影后,您将使用作为委托方法参数传递的UIImagePickerControllerMediaURL
字典中的键info
获取临时文件的文件URL。您可以使用NSFileManager
将文件复制到文档目录。