在iOS中自定义相机中捕获图像,而不在Gallery中保存图像

时间:2015-04-10 12:26:39

标签: objective-c ios8 camera photo-gallery

我想使用自定义相机,出于某些安全目的,我不想在我的图库中保存捕获图像。

先谢谢。

1 个答案:

答案 0 :(得分:0)

 UIImage *imgTaken;               
   NSString *docsDir,*imgNewPath;  
   NSData *imgData;  
   NSFileManager *filemgr;     
  dirPaths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES); 
  docsDir = [dirPaths objectAtIndex:0]; 





  -(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info   
        {  
        imgTaken = info[UIImagePickerControllerOriginalImage];  
        imgNewPath = [docsDir stringByAppendingPathComponent:[NSString stringWithFormat:@"name your image"]];
        imgData = UIImagePNGRepresentation(imgTaken);  
        [imgData writeToFile:imgNewPath atomically:YES];  
        [picker dismissViewControllerAnimated:YES completion:nil];  
    }

我希望它会对你有所帮助。