我使用以下代码捕获UIImagePickerViewController
中的视频:
- (IBAction)openVideoPicker:(id)sender {
self.video_picker = [[UIImagePickerController alloc] init];
self.video_picker.delegate = self;
self.video_picker.allowsEditing = YES;
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{
self.video_picker.sourceType = UIImagePickerControllerSourceTypeCamera;
self.video_picker.mediaTypes = [NSArray arrayWithObjects:(NSString *)kUTTypeMovie, nil];
}
else
{
self.video_picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
}
[self presentViewController:self.video_picker animated:YES completion:nil];
}
当我浏览Sand Box中的文件时,/MyApp/tmp/capture
文件夹中会捕获大量视频。因为它们占用了相当多的文件大小。什么时候会删除这些临时文件?或者我可以通过编程手动删除它们吗?
答案 0 :(得分:0)
基于this comment,您可以通过编程方式执行此操作:
NSString *videoPath = @""; // path to your video
NSFileManager *fileManager = [NSFileManager defaultManager];
if ([fileManager fileExistsAtPath: videoPath]) {
NSError *error;
// Attempt to delete the folder containing videoPath
if ([fileManager removeItemAtPath: [videoPath stringByDeletingLastPathComponent] error: &error] != YES) {
NSLog(@"Unable to delete file: %@", [error localizedDescription]);
}
}