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 camer开发者_JAVA百科a view to the user, and then use it as a simple image in the app.
Thanks
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.
精彩评论