iOS图像选择器返回视频的不存在的文件路径

时间:2016-06-14 18:36:47

标签: ios objective-c url uiimagepickercontroller

考虑以下方法,并注明其行为。

ItemContainerStyle

为什么这不起作用,我该如何解决?

1 个答案:

答案 0 :(得分:0)

正如他们的名字所示,方法Style- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { // Apparently valid URL, looks like // "file:///private/var/mobile/Containers/Data/Application/.../filename.mov" NSURL *videoURL = info[UIImagePickerControllerMediaURL]; // Always evaluates to false; no videos are saved if (UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(videoURL.absoluteString) { UISaveVideoAtPathToSavedPhotosAlbum(videoURL.absoluteString, self, @selector(video:didFinishSavingWithError:contextInfo:), nil); } } 期望路径,而不是网址。 Not the same thing.

字符串

UIVideoAtPathIsCompatibleWithSavedPhotosAlbum()

网址,由方案

组成

UISaveVideoAtPathToSavedPhotosAlbum()

路径

file:///private/var/mobile/Containers/Data/Application/.../filename.mov

传递完整的URL时,用于接受路径的函数将无法正常工作。

要解决此问题,请将file://的来电替换为/private/var/mobile/Containers/Data/Application/.../filename.mov