Itay Brenner
Itay Brenner

Reputation: 810

Automatically take a Picture

I have tried to take a picture and save it to the photo library automatically with UIImagePicker and AVFoundation, but I couldn't make it work.

I would like to take the photo when the view appears, not showing the camera view to the user, and then use it as a simple image in the app.

Thanks

Upvotes: 1

Views: 618

Answers (1)

Wienke
Wienke

Reputation: 3733

Apple actually has an entire guide devoted to this sort of thing, "Camera Programming Topics for iOS," with a subsection "Taking Pictures and Movies." There's even a sample project, "Photo Picker." Here's an excerpt, the action method for your take-a-picture button:

- (IBAction)cameraAction:(id)sender {
[self showImagePicker:UIImagePickerControllerSourceTypeCamera];
}

Note: It won't work unless [UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera] returns YES, indicating that the device has a camera.

Upvotes: 1

Related Questions