Objective c 可以给我一个不以任何方式展示的相机吗?怎么用?

Objective c 可以给我一个不以任何方式展示的相机吗?怎么用?,objective-c,ios,uiview,uiimagepickercontroller,Objective C,Ios,Uiview,Uiimagepickercontroller,我正在开发一个应用程序,我从其他人那里接管了开发工作。在用户点击一个按钮后,他们展示的相机会以模式呈现。我想有一个相机,是一个“永久”的看法,像在iOS的相机应用程序。编程指南总是说要以模式展示摄像头,但Instagram等其他应用程序都有一个摄像头,它永远是视图的一部分 我能做到这一点吗?怎么做 谢谢 是的,您可以使用AVFoundation。 导入以下标题: #import <CoreMedia/CoreMedia.h> #import <AVFoundation/AVFo

我正在开发一个应用程序,我从其他人那里接管了开发工作。在用户点击一个按钮后,他们展示的相机会以模式呈现。我想有一个相机,是一个“永久”的看法,像在iOS的相机应用程序。编程指南总是说要以模式展示摄像头,但Instagram等其他应用程序都有一个摄像头,它永远是视图的一部分

我能做到这一点吗?怎么做


谢谢

是的,您可以使用
AVFoundation
。 导入以下标题:

#import <CoreMedia/CoreMedia.h>
#import <AVFoundation/AVFoundation.h>
#import <QuartzCore/QuartzCore.h>

伟大的非常感谢,我会尽快试一试。但是,这是否仅用于视频捕获?那么照片呢?此代码仅用于在视图上显示iphone的cam live。
// Get annd start session
    AVCaptureSession *captureSession = [[AVCaptureSession alloc] init];
    [captureSession startRunning];

    // Get preview layer
    AVCaptureVideoPreviewLayer *previewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:captureSession];
    [previewLayer setVideoGravity:AVLayerVideoGravityResizeAspectFill];
    CGRect layerRect = CGRectMake(0, 0, 320, 460);
    [previewLayer setFrame:layerRect];

    // Get video device
    AVCaptureDevice *videoDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];

    if (videoDevice) {
        NSError *error;
        AVCaptureDeviceInput *videoIn = [AVCaptureDeviceInput deviceInputWithDevice:videoDevice error:&error];

        if (!error) {
            if ([captureSession canAddInput:videoIn]){
                [captureSession addInput:videoIn];
            }
        }
    }

    // Add layer to view
    [[[self view] layer] addSublayer:previewLayer];