用于UIImagePickerController
显示默认摄像机 GUI。
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.showsCameraControls = NO;
showsCameraControls
您可以通过设置隐藏默认相机控件NO
。然后,您可以通过创建一个UIView
,将您的控件和设置添加cameraOverlayView
到该视图来定义您自己的控件。
UIView *cameraControlsView = [[UIView alloc] initWithFrame:controlsFrame];
UIButton *captureButton = [[UIButton alloc] initWithFrame:buttonFrame];
[captureButton setTitle:@"Capture" forState:UIControlStateNormal];
[captureButton addTarget:self action:@selector(buttonPressed:)
forControlEvents:UIControlEventTouchUpInside];
[cameraControlsView addSubview:captureButton];
picker.cameraOverlayView = cameraControlsView;
当用户点击您的自定义捕获UIButton
时,您可以启动计时器。当计时器触发时,您进行验证并使用该takePicture
方法捕获图像。
- (void)buttonPressed:(id)sender {
[NSTimer scheduledTimerWithTimeInterval:3.0f target:self
selector:@selector(timerFired:) userInfo:nil repeats:NO];
}
- (void)timerFired:(NSTimer *)timer {
if (whateverIsOk) {
[self.picker takePicture];
)
}