ios – 在Camera模式下的UIImagePickerView在iPad上的dismissViewController上显示所有黑色

前端之家收集整理的这篇文章主要介绍了ios – 在Camera模式下的UIImagePickerView在iPad上的dismissViewController上显示所有黑色前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个应用程序,它使用UI ImagePickerView允许用户使用他们的相机拍照或使用UIImagePickerView从相机胶卷中选择一个.

获得图片后,我使用[picker presentViewController:myViewController animated:YES completion:nil]在选择器顶部显示一个不同的对话框.

如果我将我的应用程序作为iPhone应用程序(在我的iPad上)运行,当我使用[myviewController.presentingViewController dismissViewControllerAnimated:YES completion:nil]关闭myViewController时,它会返回显示CameraRoll或CameraFeed以拍摄另一张照片.

但是在iPad上,如果我选择一张图片,它可以正常工作,但如果我使用相机拍照拍照,我就会得到一个黑屏.

知道为什么吗?

解决方法

在iPad上使用不同于相机源的源时,您将在弹出窗口中呈现UIImagePickerController,您可以根据需要使用它.但是当你决定拿起源UIImagePickerControllerSourceTypeCamera时,选择器窗口呈现全屏,你有两种情况:

>如果您使用自定义控件(showsCameraControls = NO),您可以
使用相同的控制器拍摄尽可能多的照片.
>如果您使用默认控件(showsCameraControls = YES),之后
拍摄一张照片你必须关闭控制器,因为它是
再次无法使用,我猜这是你的情况.你是把
拍完照片后,下一个控制器在堆栈上,之后你
正试图回到你的选择器控制器,但它是无法使用的
更多,你可以看到黑屏.

imagePickerController的Apple文档:didFinishPickingMediaWithInfo ::

If you set the image picker’s showsCameraControls property to NO and
provide your own custom controls,you can take multiple pictures
before dismissing the image picker interface. However,if you set that
property to YES,your delegate must dismiss the image picker interface
after the user takes one picture or cancels the operation.

如果您想在这种情况下拍摄另一张照片,则必须返回基本控制器并再创建一个UIImagePickerController实例.

我希望这将有所帮助.

编辑:
IMO重建视图控制器堆栈的最简单方法是在没有动画的情况下拍摄照片后关闭选择器,之后显示下一个带动画的控制器.它会让用户感觉到,下一个控制器就会在拾取器控制器之后显示而没有任何“闪烁”.

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
    [self dismissViewControllerAnimated:NO completion:^{
        [self presentViewController:<newController> animated:YES completion:nil];
    }];
}
原文链接:https://www.f2er.com/iOS/327763.html

猜你在找的iOS相关文章