开发者

Dismissing UIImagePickerController

开发者 https://www.devze.com 2022-12-08 16:11 出处:网络
I have the following code: SecondViewController *secondView = [[SecondViewController alloc] initWithNibName:@\"SecondViewController\" bundle:nil];

I have the following code:

SecondViewController *secondView = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];

[imagePicker setSourceType:UIImagePickerControllerSourceTypeCamera];
[imagePicker setCameraOverlayView:secondView.view];
[imagePicker setShowsCameraControls:NO];

[self presentModalViewController:imagePic开发者_Python百科ker animated:YES];

My question is: How can I dismiss the ModalViewController from "SecondViewController"?


You must call the following on imagePicker from a UIImagePickerControllerDelegate method in secondView.

For example:

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    // process message
    [imagePicker dismissModalViewControllerAnimated:YES];
}


The accepted answer no longer works in iOS7. Below is the method which should be used instead.

Again, this method should be called on the UIImagePicker from the UIImagePickerControllerDelegate.

-(void) imagePickerController:(UIImagePickerController *)picker
             didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    [[picker presentingViewController] dismissViewControllerAnimated:YES completion:NULL];

}
0

精彩评论

暂无评论...
验证码 换一张
取 消