简体   繁体   中英

save an image immediately after the shutter is presed iOS

The default camera picker behavior available with the methods below is as follows: after the user presses the shutter button they are presented with a preview, and two buttons, Retake and Use.

UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.sourceType = UIImagePickerControllerSourceTypeCamera;

I want instead to mimic the behavior of the iOS default camera tool, that is as soon as an image is taken I'd like it saved and then the shutter becomes available again immediately.

Is this simple to do or do I need to write a custom toolbar using the cameraOverlayView property and a custom method that fires the shutter?

picker.cameraOverlayView = [[UIView alloc] init];
[picker.cameraOverlayView addSubview:bottomToolBar]; 

Seems that what I needed to do was create an instance of UIView as below and it works.

picker.cameraOverlayView = [[UIView alloc] initWithFrame:CGRectMake(
                                                  0, 0, 640, 960)];

for my experiment I just created a UIButton that targets a method called takePicture. takePicture calls [picker takePicture];which in turn calls imagePickerController:didFinishPickingImage:editingInfo: via delegation, which calls UIImageWriteToSavedPhotosAlbum(image,nil,nil,nil);. The picker is not dismissed so I can continue taking pictures.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM