调整UIImagePickerController视频采集界面大小

发布于 2024-12-03 04:33:23 字数 273 浏览 0 评论 0原文

我正在为我的 ipad 应用程序使用 splitviewcontroller,其中我需要在 detailViewController 中以 530 px 宽和 360 px 高的尺寸捕获视频。我尝试使用 UIImagePickerController 来捕获视频,但我无法更改视频捕获界面的大小。我无法在应用程序中进行全屏视频捕获。有没有办法调整UIImagePickerController视频采集界面的大小。非常感谢您的回答。抱歉没有在这里添加屏幕截图。我的声誉不允许这样做。

I am using splitviewcontroller for my ipad application in which I need to capture video in the detailViewController in a dimension of 530 px width and 360 px height. I tried using UIImagePickerController for capturing video but i am unable to change the size of the video capture interface. I cannot afford a full screen video capture in the app. Is there a way to resize the video capture interface of UIImagePickerController. Thanks a lot for your answers. Sorry for not adding up an screenshot here. My reputation count doesn't permit it.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

最冷一天 2024-12-10 04:33:23

据我所知,您无法使用 UIImagePickerController 来执行此操作。但是您可以使用 AVCamCaptureManager 和 AVCamRecorder 类轻松完成此操作。 Apple 在其开发人员网站上构建了一个演示程序 这里。它被命名为AVCam。简单来说,它的作用是当您单击打开相机时,它会调用负责打开 iPhone 相机并录制视频或捕获音频的类和方法。它调用与 UIImagePickerController 调用的相同的类。

您将在该演示代码中找到一个小的 UIView 对象,它显示相机的源。您可以根据需要调整该视图的大小,相机的输入将显示在该区域中。当我想要调整相机输入源的大小并拍摄照片时,它对我有用。我希望它也适合你。

You won't be able to do so using UIImagePickerController as far as I know. But you can do it easily using AVCamCaptureManager and AVCamRecorder classes. Apple has a demo program build on its developer site here. It is named AVCam. In simple words what it does is when you click to open the camera, it calls the classes and methods which are responsible for opening the iPhone's camera and record video or capture audio. It calls the same classes which are called by UIImagePickerController.

You'll find a small UIView object in that demo code which displays the camera's feed. You can resize that view as per the size you want and the camera's input will be displayed in that much area. It worked for me when I wanted to resize the camera's input feed and capture photos. I hope it works for you as well.

深府石板幽径 2024-12-10 04:33:23

我刚刚找到了一种在 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];

I just found a possible way to resize UIImagPickerController video capture interface on iPad. The basic idea is to use UIPopoerController's dimension to resize the UIImagPickerController's view and then add it to your custom view.

The detailed code and description are listed below:

//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];   

Note : when you finish video capture or cancel it, you need to dismiss the popover and remove the container's view from your custom view.

[popoverView dismissPopoverAnimated:YES];
[[camView.subviews lastObject] removeFromSuperview];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文