gpt4 book ai didi

iphone - NSInvalidArgumentException – 当我尝试将捕获的视频复制到文档文件夹时应用程序终止

转载 作者:行者123 更新时间:2023-12-03 20:16:53 25 4
gpt4 key购买 nike

我想尝试一下群众的智慧……因为我现在很沮丧。提前致谢。

这是我的代码:

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

NSLog(@"信息:%@",info);

NSString *newFilename = [NSString stringWithFormat:@"%@/%@.mov", [NSHomeDirectory() stringByAppendingPathComponent:@"文档"], [NSString stringWithFormat:@"%d", (long)[[NSDate date] timeIntervalSince1970]]];

NSLog(@"newFilename: %@",newFilename);

NSFileManager *filemgr = [NSFileManager defaultManager];

NSError *err; if ([filemgr copyItemAtPath:[info objectForKey:@"UIImagePickerControllerMediaURL"] toPath:newFilename 错误:&err] == YES) NSLog(@"移动成功"); 别的 NSLog(@"移动失败");

这是日志:

 2010-05-16 18:19:01.975 erlkoenig[7099:307] info: {
UIImagePickerControllerMediaType = "public.movie";
UIImagePickerControllerMediaURL = "file://localhost/private/var/mobile/Applications/BE25F9B5-2D08-4B59-8B62-D04DF7BB7E5B/tmp/-Tmp-/capture-T0x108cb0.tmp.8M81HU/capturedvideo.MOV";
}
newFilename: /var/mobile/Applications/BE25F9B5-2D08-4B59-8B62-D04DF7BB7E5B/Documents/1274026741.mov

[NSURL fileSystemRepresentation]: unrecognized selector sent to instance 0x1c1f90
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSURL fileSystemRepresentation]: unrecognized selector sent to instance 0x1c1f90

最佳答案

我可以理解您的逻辑,但有一个基本问题:这不是保存视频的方式

请参阅下面的粗略示例,无需进行相关错误检查。

(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info

{

.... code here .....

NSString* videoURL= [info objectForKey:UIImagePickerControllerMediaURL];

//remember to test that the video is compatible for saving to the photos album

UISaveVideoAtPathToSavedPhotosAlbum(videoURL, self, @selector(video:didFinishSavingWithError:contextInfo:), nil);

.... code here .....

}

关于iphone - NSInvalidArgumentException – 当我尝试将捕获的视频复制到文档文件夹时应用程序终止,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2844580/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com