ios - UIImagePickerController 和外部显示

标签 ios ipad uiimagepickercontroller

我正在编写一个 iPad 信息亭类型的应用程序,它允许访问者使用前置摄像头录制视频并查看相机胶卷中针对外部显示器的现有视频。我只是在学习 XCode,并在针对 iOS 5 的 Xcode 4.4.1 中工作。最近似乎发生了很多变化,这使得学习变得更加困难,所以我试图让事情尽可能简单,这就是我为什么使用 UIImagePicker。

一切都如我所愿,但有一个异常(exception)——我无法在外接显示器和 iPad 之间随意切换。当用户录制视频时,它在 iPad 上是全屏的。没关系,但是在他们停止录制后,视频会立即发送到外部显示器以供批准,并且 UIPopover 中会留下一个占位符图像。我宁愿看到/做的是在 iPad 上保持视频预览全屏,或者将视频定位到 UIPopover。

原因是从用户访问 iPad 的位置不容易看到外部显示器。因此,他们被要求批准(单击使用)他们无法真正看到的东西。把它放在iPad上会好得多。下面的代码是我用来记录的。

其他一切都很好,我希望用户从库中选择视频并显示在外接显示器上,因为这是默认行为,它可以正常工作。

到目前为止,我能找到的最接近的答案是:UIImagePickerController in an existing UIPopoverController

有没有一种简单的方法可以禁用外部显示器或阻止发送视频预览?

   - (IBAction)useCameraRoll:(id)sender
{
    if([self.popoverController isPopoverVisible]) {
        [self.popoverController dismissPopoverAnimated:YES];
    } else {
        if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeSavedPhotosAlbum])
        {

            UIImagePickerController *imagePicker =
            [[UIImagePickerController alloc] init];
            imagePicker.delegate = self;
            imagePicker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
            imagePicker.mediaTypes = [NSArray arrayWithObjects:(NSString *) kUTTypeMovie, nil];

            imagePicker.allowsEditing = NO;

            self.popoverController = [[UIPopoverController alloc] initWithContentViewController:imagePicker];
            //self.popoverController = [[UIPopoverController alloc] setContentViewController:animated];

            self.popoverController.delegate = self;

            [self.popoverController
             presentPopoverFromBarButtonItem:sender  permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];

            newMedia = NO;


        }
    }
}

最佳答案

巧合的是,我一直在使用 iPad 开发类似的信息亭应用程序。就我而言,它利用一些增强现实在外部显示器上显示相关内容。我使用 iPad 屏幕作为增强现实体验的配置面板。

我发现,解决这个问题的最佳方法是为每个显示器使用带有两个 UIScreens 的单独窗口。这使您能够正确地制作体验。我不确定你是否已经在使用这种方法,但如果你没有,那么这就是要走的路。

要开始使用,您可以阅读 ExternalDisplay代码示例。摘自:

从 iOS 开发人员库中的 ExternalDisplay 示例代码:

To display content on an external display, do the following:

  1. Use the screens class method of the UIScreen class to determine if an external display is available.

  2. If an external screen is available, get the screen object and look at the values in its availableModes property. This property contains the configurations supported by the screen.

  3. Select the UIScreenMode object corresponding to the desired resolution and assign it to the currentMode property of the screen object.

  4. Create a new window object (UIWindow) to display your content.

  5. Assign the screen object to the screen property of your new window.

  6. Configure the window (by adding views or setting up your OpenGL ES rendering context).

  7. Show the window.



此外,UIScreen文档很有帮助。

关于ios - UIImagePickerController 和外部显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12224487/

相关文章:

ios - 如何在 iPad SplitViewController 中使用 SWRevealViewController

camera - ios 10 对未渲染的 View 进行快照会生成空快照

iphone - ELCImagePickerController 的 Indicatorview

objective-c - iPhone视频录制: "cameraCaptureMode 1 not available because mediaTypes does contain public.movie"

在 UIImagePickerController 上使用前置摄像头时 iOS 方向错误

ios - Http get with Swift-2 中的查询参数

ios - 如何在一起滚动的 UITableView 顶部添加一个 View ,但在滚动后坚持到顶部

ios - 在 TableView 中添加额外的行

iOS canAuthenticateAgainstProtectionSpace 方法不是每次都调用

ios - 在 iOS 中,你可以使用 NSDictionary 作为文本文件吗?