简体   繁体   English

如何在iPhone中使用相机捕获整个屏幕?

[英]How to capture whole screen with camera in iPhone?

I have an application in which i open camera without camera controls and i used my custom controls. 我有一个应用程序,其中打开没有摄像头控件的摄像头,并且使用了自定义控件。
Now i want that camera capture whole screen and my custom controls display in front of camera view but don't know how to do that. 现在,我希望该摄像头能够捕获整个屏幕,并且我的自定义控件显示在摄像头视图的前面,但是不知道该怎么做。
Below is my code 下面是我的代码

-(void) cameraOpen
{
    imgpicker=[[UIImagePickerController alloc]init];
    imgpicker.delegate=self;
    imgpicker.sourceType=UIImagePickerControllerSourceTypeCamera;
    imgpicker.showsCameraControls=FALSE;
    imgpicker.wantsFullScreenLayout=TRUE;

    UIView *newView=[[UIView alloc] initWithFrame:CGRectMake(0,416,320,480)];
    newView.backgroundColor=[UIColor clearColor];
    [newView addSubview:cameraOptionView];
    imgpicker.cameraOverlayView=newView;

    [self presentModalViewController:imgpicker animated:YES];
}

What happen currently is at bottom it shows white space and my new view in that space. 当前发生的是在底部显示空白区域以及该空间中的新视图。
I want whole screen captured by camera and my custom view for controls should on front of camera. 我希望相机捕获整个屏幕,并且控件的自定义视图应位于相机前面。
Thanks in advance. 提前致谢。

You can't have a full screen camera since the the camera aspect ratio (4:3) is not the same as the one as the screen (2:3). 您无法拥有全屏摄像头,因为摄像头的宽高比(4:3)与屏幕的高宽比(2:3)不同。

You can however, stretch the image so that it will fill the screen. 但是,您可以拉伸图像,使其充满整个屏幕。 I do not recommend that, since the image will probably not look right. 我不建议这样做,因为图像可能看起来不正确。 For that, you'll use AV Foundation , AVCaptureVideoPreviewLayer in particular. 为此,您将特别使用AV FoundationAVCaptureVideoPreviewLayer

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM