Ios 解除自定义UIImagePickerController

Ios 解除自定义UIImagePickerController,ios,Ios,我以以下方式加载UIImagePickerController: - (void) launchCamera { // Set up the camera CustomCamera *cameraController = [[CustomCamera alloc] init]; cameraController.sourceType = UIImagePickerControllerSourceTypeCamera; cameraController.delegate = self; cam

我以以下方式加载UIImagePickerController:

- (void) launchCamera {

// Set up the camera
CustomCamera *cameraController = [[CustomCamera alloc] init];
cameraController.sourceType = UIImagePickerControllerSourceTypeCamera;
cameraController.delegate = self;

cameraController.showsCameraControls = NO;
cameraController.navigationBarHidden = YES;
cameraController.toolbarHidden = YES;

// overlay on top of camera lens view
UIImageView *cameraOverlayView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"camera_overlay.png"]];
cameraOverlayView.alpha = 0.0f;
cameraController.cameraOverlayView = cameraOverlayView;

// animate the fade in after the shutter opens
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDelay:2.2f];
cameraOverlayView.alpha = 1.0f;
[UIView commitAnimations];

[self presentModalViewController:cameraController animated:YES];
}
问题是,我不知道如何排除它。当我尝试

[cameraController dismissViewControllerAnimated:YES completion: nil];

我得到一个红色的错误。cameraController只是一个UIImagePickerController,这是因为cameraController没有做演示,而self对象做了。您正在调用self-present而不是cameraController

错误出现在[cameraController DismissViewControllerInitiated:YES completion:nil];已通过执行[cameraController presentModalViewController:cameraController动画:是];而消失;。但控制器仍然没有从屏幕上移除