首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >AVCam到情节提要-相机不显示

AVCam到情节提要-相机不显示
EN

Stack Overflow用户
提问于 2013-01-15 19:59:21
回答 1查看 455关注 0票数 0

我从苹果公司下载了AVCam示例,并尝试将xib文件迁移到Storyboard。

问题是"newCaptureVideoPreviewLayer“无法在视图中显示视频...视图将outlet引用到"videoPreviewView“这是视频应该出现的视图。

这是AVCam示例中的代码,我只是粘贴了代码并删除了不必要的内容:

代码语言:javascript
复制
- (void)viewDidLoad
{
    if ([self captureManager] == nil) {
    AVCamCaptureManager *manager = [[AVCamCaptureManager alloc] init];
    [self setCaptureManager:manager];
    [manager release];

    [[self captureManager] setDelegate:self];

    if ([[self captureManager] setupSession]) {
        // Create video preview layer and add it to the UI
        AVCaptureVideoPreviewLayer *newCaptureVideoPreviewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:[[self captureManager] session]];
        UIView *view = [self videoPreviewView];
        CALayer *viewLayer = [view layer];
        [viewLayer setMasksToBounds:YES];

        CGRect bounds = [view bounds];
        [newCaptureVideoPreviewLayer setFrame:bounds];

        [newCaptureVideoPreviewLayer setVideoGravity:AVLayerVideoGravityResizeAspectFill];

        [viewLayer insertSublayer:newCaptureVideoPreviewLayer below:[[viewLayer sublayers] objectAtIndex:0]];

        [self setCaptureVideoPreviewLayer:newCaptureVideoPreviewLayer];
        [newCaptureVideoPreviewLayer release];

        // Start the session. This is done asychronously since -startRunning doesn't return until the session is running.
        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
            [[[self captureManager] session] startRunning];
        });
    }
}

[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}

有人有什么建议吗?

EN

回答 1

Stack Overflow用户

发布于 2013-03-05 21:33:59

您可能希望确保您的camerapreview视图是故事板中的顶子视图。最后添加或使用BringSubviewToFront接口。

我猜如果你按下“拍摄照片”,相机会把一张照片保存到你的相机卷轴上?如果没有,可能是初始化代码有问题。我不得不修改iOS6的ismirrored弃用代码。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14337234

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档