How to take a picture with custom camera view?
I want to release the shutter as soon as the user tabs on the screen. I have working code for displaying the camera in fullscreen mode. How can I trigger the shutter by a touch?
- (IBAction) takePicture { if (!self.imgPicker) { self.imgPicker = [[UIImagePickerController alloc] init]; self.imgPicker.allowsEditing = NO; self.imgPicker.delegate = self; } if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) { self.imgPicker.sourceType = UIImagePickerControllerSourceTypeCamera; self.imgPicker.showsCameraControls = NO; self.imgPicker.wantsFullScreenLayout = YES; CGAffineTransform cameraTransform = CGAffineTransformMakeScale(1.132, 1.132); self.imgPicker.cameraViewTransform = cameraTransform; UIView *headsUpView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 480, 320)]; [self.imgPicker setCameraOverlayView:headsUpView]; } else { NSLog(@"Camera not available."); self.imgPicker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum; } [self presentModalViewController:self.imgPicker animated:YES]; }
You should use the takePicutre method and then detect any touches on the screen.
http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIImagePickerController_Class/UIImagePickerController/UIImagePickerController.html#//apple_ref/occ/instm/UIImagePickerController/takePicture
Something like this
-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [[event allTouches] anyObject];
self.imgPicker.takePicture;
}
链接地址: http://www.djcxy.com/p/14764.html
上一篇: 如何在iPhone中存储捕获的视频的时间段(持续时间)?
下一篇: 如何使用自定义相机视图拍摄照片?