admin管理员组文章数量:1535375
2024年5月24日发(作者:)
iOS AVCaptureVideoPreviewLayer 在 UIView 中没有显示?
iOS AVCaptureVideoPreviewLayer 在 UIView 中没有显示?[英]iOS
AVCaptureVideoPreviewLayer not showing in UIView? The Problem I have a sample
application from Apple (SquareCam) that I’m using as reference to create a
custom
interface for a camera. I’m using the AVFoundation framework. If I build and run the
project from Apple, the app runs as expected. However, if I take the same code from
that
project and place it in a new project in Xcode, the video preview will not display.
我有一个来自 Apple(SquareCam)的示例应用程序,我正在使用它作为参考来为相机
创建自定义界面。我正在使用 AVFoundation 框架。如果我从 Apple 构建并运行该项
目,该应用程序将按预期运行。但是,如果我从该项目中获取相同的代码并将其放在
Xcode 中的新项目中,则不会显示视频预览。
I have simplified the code down to the essential components to run a video preview
layer. Again, this code runs fine as is in the Apple (SquareCam) project, but does
not
display in my new project.
我已将代码简化为运行视频预览图层的基本组件。同样,此代码在
Apple(SquareCam)项目中运行良好,但不会显示在我的新项目中。
The Code - (void)setupAVCapture { NSError *error = nil; AVCaptureSession *session
= [AVCaptureSession new]; if ([[UIDevice currentDevice] userInterfaceIdiom] ==
UIUserInterfaceIdiomPhone)
setSessionPreset:AVCaptureSessionPreset640x480];
[session
else
[session
setSessionPreset:AVCaptureSessionPresetPhoto]; // Select a video device, make an
input
AVCaptureDevice *device = [AVCaptureDevice
AVCaptureDeviceInput defaultDeviceWithMediaType:AVMediaTypeVideo];
*deviceInput = [AVCaptureDeviceInput deviceInputWithDevice:device error: error]; if
([session canAddInput:deviceInput]) [session addInput:deviceInput]; previewLayer =
版权声明:本文标题:【推荐下载】iOS AVCaptureVideoPreviewLayer在UIView中没有显示 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/dianzi/1716481573a505199.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论