我正在尝试在录制后立即将电影保存在文档文件夹中。
这是我的代码:
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
NSString *moviePath = [[info objectForKey:UIImagePickerControllerMediaURL] path];
[self dismissViewControllerAnimated:YES completion:nil];
NSLog(@"path from image picker: %@", moviePath);
NSFileManager* fileManager = [NSFileManager defaultManager];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory , NSUserDomainMask, YES);
NSString* documentsDir = [paths objectAtIndex:0];
NSLog(@"%@",documentsDir);
[fileManager moveItemAtPath:moviePath toPath:documentsDir error:nil];
NSArray *files = [fileManager contentsOfDirectoryAtPath:documentsDir
error:nil];
for (id object in files) {
NSLog(@"%@",object);
}
}
正如您可能猜到的那样,它不起作用。
第一个日志说:图像选择器的路径:/private/var/mobile/Applications/6630FBD3-1212-4ED0-BC3B-0C23AEEFB267/tmp/capture-T0x1e575330.tmp.SQQ2C5/capturedvideo.MOV
秒日志显示:/var/mobile/Applications/6630FBD3-1212-4ED0-BC3B-0C23AEEFB267/Documents
任何人都知道为什么它不起作用?