【问题标题】:Remove temporary captured video produced by UIImagePickerController删除由 UIImagePickerController 生成的临时捕获视频
【发布时间】:2013-07-25 09:52:41
【问题描述】:

我使用以下代码在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];
}

当我浏览沙盒中的文件时,/MyApp/tmp/capture 文件夹中有很多视频捕获。因为它们占据了相当多的文件大小。这些临时文件何时会被删除?还是我可以通过编程手动删除它们?

【问题讨论】:

    标签: uiimagepickercontroller


    【解决方案1】:

    基于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]);
        }
    }
    

    【讨论】:

      猜你喜欢
      • 2013-12-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-06-08
      • 1970-01-01
      • 1970-01-01
      • 2016-01-20
      相关资源
      最近更新 更多