0

I'm new to ios, please help me out.

- (IBAction)btn_actionTakePicture:(UIButton *)sender {

    UIImagePickerController *picker = [[UIImagePickerController alloc] init];
    picker.delegate = self;
    picker.allowsEditing = YES;
    picker.sourceType = UIImagePickerControllerSourceTypeCamera;
    [self presentViewController:picker animated:YES completion:NULL];
}

I press the take picture button, and this code runs, the camera comes up and i can take a photo.

- (NSArray *) listFiles {

    NSURL *bundleRoot = [[NSBundle mainBundle] bundleURL];
    NSFileManager *fm = [NSFileManager defaultManager];
    NSArray * dirContents =
        [fm contentsOfDirectoryAtURL:bundleRoot
          includingPropertiesForKeys:@[]
                             options:NSDirectoryEnumerationSkipsHiddenFiles
                               error:nil];
    return dirContents;
}

This is where I check file contents to see if the photo was taken and saved in the directory, I basically put the returned (NSArray *) in an NSLog to see the list of files and if there are photos there or not, I did not see any saved jpgs.

Where are the files being saved to, I also checked the photo roll, they aren't being saved there either.

lost
  • 81
  • 1
  • 2
  • 8
  • Do you check immediately after taking photo normally photo saving takes some time? – jailani Dec 26 '13 at 12:22
  • i've taken multiple photos, over a 1 hour span – lost Dec 26 '13 at 12:24
  • UIImage *image = savingImage; UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil); this will save image in camera roll. if your requirement is different let me know where you want to save image – Charan Giri Dec 26 '13 at 12:34
  • @Charan Giri, I get an error, with `UIImage *image = savingImage;`, Use of undeclared identifier 'savingImage' – lost Dec 26 '13 at 13:13
  • @Charan Giri, How do I get the `savingImage` with the photo I took in the camera to be more specific. – lost Dec 26 '13 at 13:20

1 Answers1

0

The camera app's files are saved to a location on the hard drive that your app cannot read, due to security restrictions.

The API will return the image in RAM and you are responsible for writing it to a file yourself, in a location of the disk that you do have access to.

Have a look at the sample code for UIImagePickerController to see the method your delegate needs to implement to access the image.

Beware the image will be a 32 bit + alpha channel bitmap image with no compression. You probably want to write it to disk as a jpeg image.

Abhi Beckert
  • 32,787
  • 12
  • 83
  • 110