gpt4 book ai didi

ios - 相机模式下的 UIImagePickerView 在 iPad 上的 dismissViewController 上显示全黑

转载 作者:可可西里 更新时间:2023-11-01 03:47:22 25 4
gpt4 key购买 nike

我有一个应用程序使用 UIImagePickerView 允许用户使用他们的相机拍照或使用 UIImagePickerView 从相机胶卷中选择一张照片。

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

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

但在 iPad 上,如果我选择图片,它会起作用,但如果我使用相机供稿拍照,我只会看到黑屏。

知道为什么吗?

最佳答案

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

  1. 如果您使用自定义控件 (showsCameraControls = NO),您可以使用同一个 Controller 拍摄尽可能多的照片。
  2. 如果您使用默认控件 (showsCameraControls = YES),则在拍一张照片,你必须关闭 Controller ,因为它是再次无法使用,我想这是你的情况。你把拍照后堆栈中的下一个 Controller ,之后你正在尝试返回到您的选择器 Controller ,但它无法使用任何更多,您都可以看到黑屏。

imagePickerController:didFinishPickingMediaWithInfo: 的 Apple 文档:

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.

如果你想在这种情况下拍摄另一张照片,你必须返回到你的基本 Controller 并再次创建 UIImagePickerController 实例。

希望对您有所帮助。

编辑:IMO 重建 View Controller 堆栈的最简单方法是在拍摄没有动画的照片后关闭选择器,然后显示下一个带有动画的 Controller 。它会给用户一种感觉,下一个 Controller 显示在选择器 Controller 之后,没有任何“闪烁”。

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
[self dismissViewControllerAnimated:NO completion:^{
[self presentViewController:<newController> animated:YES completion:nil];
}];
}

关于ios - 相机模式下的 UIImagePickerView 在 iPad 上的 dismissViewController 上显示全黑,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15427305/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com