如何解除iPad上的UIImagePickerController?

时间:2021-12-07 00:00:31

I have a problem with regarding how to dismiss the UIImagePickerController on an iPad. I have implemented a camera with a custom cameraOverlayView that has a button on it to access the photoLibrary.The iPad used the same code as the iPhone version to present the picker in order to show the photoLibrary. However, when I pressed the cancel button it goes back to a black page with nothing on it (the same code would take the iPhone to the custom camera view). Does iPad have a different method for dismissing viewControllers or do I have to use a popover to access the photoLibrary?

关于如何解除iPad上的UIImagePickerController,我遇到了问题。我已经实现了一个带有自定义cameraOverlayView的相机,其上有一个按钮来访问photoLibrary.iPad使用与iPhone版相同的代码来呈现选择器以显示photoLibrary。但是,当我按下取消按钮时,它会返回到黑色页面上没有任何内容(相同的代码会将iPhone带到自定义相机视图)。 iPad有不同的方法来解除viewControllers,还是我必须使用popover来访问photoLibrary?

Here is my code:

这是我的代码:

- (void)imagePickerControllerDidCancel:(UIImagePickerController*)picker
{
    CDVCameraPicker* cameraPicker = (CDVCameraPicker*)picker;
    if ([self popoverSupported]){
            NSLog(@"cancel");
        [[cameraPicker presentingViewController] dismissViewControllerAnimated:YES completion:nil];
    }
    else if (isSelectingFromPhotoAlbum == true){
        [[cameraPicker presentingViewController] dismissViewControllerAnimated:YES completion:nil];
    }
}

The NSLog message did appear on console, so I am assuming that iPad is recognized, but it does not go back to the previous view.

NSLog消息确实出现在控制台上,因此我假设iPad已被识别,但它不会返回到上一个视图。

Any thoughts on what happened?

对发生了什么的任何想法?

1 个解决方案

#1


0  

Technically, here's you should have to do:

从技术上讲,这是你应该做的:

- (void)imagePickerControllerDidCancel:(UIImagePickerController *)imagePicker
{
     [imagePicker dismissViewControllerAnimated:NO completion:nil];
}

#1


0  

Technically, here's you should have to do:

从技术上讲,这是你应该做的:

- (void)imagePickerControllerDidCancel:(UIImagePickerController *)imagePicker
{
     [imagePicker dismissViewControllerAnimated:NO completion:nil];
}