我在我的ipad应用程序中使用splitviewcontroller
,我需要在detailViewController
中以530像素宽度和360像素高度捕获视频。我尝试使用UIImagePickerController
来捕获视频,但我无法更改视频捕获界面的大小。我在应用程序中无法承受全屏视频捕获。有没有办法调整UIImagePickerController
的视频捕获界面的大小。非常感谢你的回答。很抱歉没有在此处添加屏幕截图。我的声誉计数不允许。
答案 0 :(得分:2)
据我所知,你无法使用UIImagePickerController这样做。但您可以使用AVCamCaptureManager和AVCamRecorder类轻松完成。 Apple在其开发者网站here上构建了一个演示程序。它被命名为AVCam。简单来说,当您单击打开相机时,它会调用负责打开iPhone相机并录制视频或捕获音频的类和方法。它调用由UIImagePickerController调用的相同类。
您将在该演示代码中找到一个小UIView对象,该对象显示摄像机的源。您可以根据需要调整视图大小,摄像机的输入将显示在该区域中。当我想调整相机的输入源并拍摄照片时,它对我有用。我希望它对你也有用。
答案 1 :(得分:0)
我刚刚找到了一种在iPad上调整UIImagPickerController视频捕获界面大小的方法。基本思想是使用UIPopoerController的维度来调整UIImagPickerController的视图大小,然后将其添加到自定义视图中。
详细的代码和说明如下:
//In the following code, videoRecorder is an UIImagPickerController
//1. Create a container view controller and load UIImagPickerController's view
UIViewController *containerController = [[UIViewController alloc] init];
containerController.contentSizeForViewInPopover = CGSizeMake(320, 240);
[containerController.view addSubview:videoRecorder.view];
//2. Add the container view controller in a UIPopoerController and present the popover outside the visible area on the screen (you can't see it but the popover was presented)
popoverView = [[UIPopoverController alloc] initWithContentViewController:containerController];
popoverView.passthroughViews = [NSArray arrayWithObjects:self.view, nil];
[popoverView setPopoverContentSize:CGSizeMake(320, 240)];
[popoverView presentPopoverFromRect:CGRectMake(0, -1024, 1, 1) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionLeft animated:YES];
//3. Reset the frame of UIImagPickerController's view to meet the frame of its container - this is important to resize the UIImagPickerController's view and must do this step after the popover was presented.
[videoRecorder.view setFrame:containerController.view.frame];
//4. Add the container view controller's view to your custom view - in this example, it is 'camView' with the size 320 x 240
[camView addSubview:containerController.view];
注意:完成视频捕获或取消后,您需要关闭弹出窗口并从自定义视图中删除容器的视图。
[popoverView dismissPopoverAnimated:YES];
[[camView.subviews lastObject] removeFromSuperview];