开发者社区> 问答> 正文

IOS应用调用摄像头拍摄后点击USE保存视频到本地的方法?

当拍摄完毕后,点击USE就保存到本地相册里面,应该在这个方法:-(void)imagePickerController: (UIImagePickerController )picker didFinishPickingMediaWithInfo:(NSDictionary )info里面如何设置?拍摄完毕后并进行选中状态,如何写该方法?

展开
收起
杨冬芳 2016-07-01 18:01:02 2459 0
1 条回答
写回答
取消 提交回答
  • IT从业
    • (void)imageDismiss:(UIImagePickerController *)picker

    {

    [picker dismissModalViewControllerAnimated:YES];
    

    }

    pragma mark - UIImagePickerDelegate

    • (void)imagePickerController:(UIImagePickerController )picker didFinishPickingImage:(UIImage )image editingInfo:(NSDictionary *)editingInfo {

    [self performSelector:@selector(imagePickerController:didFinishPickingMediaWithInfo:)];

    }

    • (void)imagePickerController:(UIImagePickerController )picker didFinishPickingMediaWithInfo:(NSDictionary )info {

    [self performSelector:@selector(imageDismiss:) withObject:picker afterDelay:1.0f];

    UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
    
    
    
    // 保存图片
    
    if (picker.sourceType == UIImagePickerControllerSourceTypeCamera) {
    
        [NSThread detachNewThreadSelector: @selector(_saveImage:) toTarget:self withObject:image];
    
    }
    

    }

    • (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {

      [self performSelector:@selector(imageDismiss:) withObject:picker afterDelay:1.0f];
      

    }

    • (void)_saveImage:(UIImage* )image{

      @autoreleasepool {
      
          UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil);
      
      }
      

    }

    这个方法是保存图片的方法,我也试过了,可以用。很不错,但是有保存视频的方法吗?

    2019-07-17 19:50:19
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
手淘iOS性能优化探索 立即下载
From Java/Android to Swift iOS 立即下载
深入剖析iOS性能优化 立即下载