我需要使用自己的设计自定义默认的UIImagePicker编辑视图。我使用以下代码创建了图像选择器。
UIImagePickerController *imagePicker = [[UIImagePickerController alloc]init];
imagePicker.delegate = self;
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.allowsEditing = TRUE;
[self presentViewController:imagePicker animated:YES completion:nil];
这将显示默认的摄像机视图,一旦我拍照,它将导航到默认的编辑屏幕,其中包括' Retake'和'选择'纽扣。我需要用自己的设计替换这个屏幕。是否有任何可能的方法来实现这一目标?
答案 0 :(得分:0)
您需要创建一个自定义视图控制器并将其覆盖到默认的pickerViewController。
以下是我的一个项目的示例代码:
- (BOOL)startCameraControllerFromViewController:(UIViewController *)controller withAnimation:(BOOL)animated {
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera] == NO) {
ShowErrorMessage(nil, @"Your device doesn't support camera.");
return NO;
}
CameraOverlayViewController *cameraOverlay = [controller.storyboard instantiateViewControllerWithIdentifier:FuCameraOverlayID];
cameraOverlay.delegate = self;
self.cameraOverlay = cameraOverlay;
UIImagePickerController *cameraUI = [[UIImagePickerController alloc] init];
cameraUI.sourceType = UIImagePickerControllerSourceTypeCamera;
cameraUI.allowsEditing = NO;
cameraUI.showsCameraControls = NO;
cameraUI.delegate = self;
[cameraUI setCameraOverlayView:self.cameraOverlay.view];
self.imagePicker = cameraUI;
[controller presentViewController:self.imagePicker animated:animated completion:^{
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];
}];
return YES;
}