2011-09-06 30 views
3

我使用splitviewcontroller爲我的ipad應用程序,其中我需要在detailViewController捕捉視頻在530像素寬度和360像素高度的尺寸。我嘗試使用UIImagePickerController捕捉視頻,但我無法更改視頻捕捉界面的大小。我買不起應用程序中的全屏視頻。有沒有辦法調整UIImagePickerController的視頻捕捉界面的大小。非常感謝你的回答。對不起,這裏沒有添加屏幕截圖。我的聲譽計數不允許。調整大小UIImagePickerController視頻捕捉接口

回答

2

就我所知,您將無法使用UIImagePickerController。但是你可以使用AVCamCaptureManager和AVCamRecorder類輕鬆完成。 Apple在其開發者網站here上建有一個演示程序。它被命名爲AVCam。簡單地說,它的功能是當你點擊打開相機時,它會調用負責打開iPhone相機並記錄視頻或捕獲音頻的類和方法。它調用由UIImagePickerController調用的相同的類。

您會在該演示代碼中找到一個小UIView對象,該對象顯示相機的提要。您可以根據所需的尺寸調整視圖大小,並在相當多的區域顯示相機的輸入。當我想調整相機的輸入信號並捕捉照片時,它適用於我。我希望它也適合你。

+0

示例代碼:\t 的Xcode 9.0,iOS的11.0 SDK **。你可以在這裏提供解決方案代碼,你如何調整視頻幀感謝.. :) – vaibhav

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