开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜