- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我已经找到并阅读了这个 tutorial .确实很好!我故意使用“阅读”这个词。早知道就不来这里问了。
现在:我试图将我读过的内容插入到我的应用程序中。我需要带有静态图像和相机预览控件的不同叠加层。我需要相机预览在应用程序的其余部分旋转时保持静止。我需要它是 AVFoundation,因为会有很多额外的图像和相机功能。我想旋转所有应用程序,但相机预览。一个自制的容器 View Controller 将成为铰链点。在它之外,应用程序旋转。它控制它的 child 的旋转,我希望能够减少我的手动旋转到所述容器 View Controller 的相机预览 subview Controller 的覆盖。
(此外:除此之外,我还使用链接的 Storyboard、ARC 和 CoreData(稍后用于照片))
要点是:我在容器 View Controller 容器 View 中有这个 View Controller 。那就是我想要预览的那个。我想要另一个容器 View Controller subview Controller 中的静止图像,第三个 subview Controller 是照片的浏览器。稍后会有按钮和手势从一个 child 导航到另一个。捕获 session 管理器是容器 View Controller 的一个属性,即父级。
我已经设置了所有@properties(在捕获 session 管理器、容器 View Controller 和相机预览 View Controller 中),当它们不存在时将被创建。我已经为相机预览 View Controller 提供了一个捕获 session 管理器的属性,但应该只是指向父 session 管理器的指针(懒惰或 fatal error ?)。
据我所知,通过调试器单步执行,连接已经建立。现在,在相机预览 View Controller 的 viewDidLoad 方法中,我尝试显示预览层。
然后我看到... ...只有一个空白的白色 View :(
我可能忘记了什么?
此时应该已经建立了父子连接。 embed segue 设置子项的捕获管理器:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([[segue identifier] isEqualToString:@"EmbedCameraPreview"])
{ // present destination view
if ([[segue destinationViewController] isKindOfClass:[CameraPreviewViewController class]]) {
CameraPreviewViewController * destinationVC = (CameraPreviewViewController *)[segue destinationViewController];
[destinationVC setCaptureManager:[self captureManager]];
}
[self addChildView:[segue destinationViewController]];
}
}
- (void) addChildView: (UIViewController*) content {
[self addChildViewController:content];
content.view.frame = [self maxFrame];
[content didMoveToParentViewController:self];
}
- (CGRect) maxFrame {
return [[[self view] layer] bounds];
}
child 的捕获管理器是私有(private)的(在 .m 文件中),具有公共(public) setter :
接口(interface):
@property (retain, nonatomic) CaptureSessionManager *captureManager;
实现:
@synthesize captureManager;
- (void)setCaptureManager:(CaptureSessionManager *) newCaptureManager {
if (captureManager != newCaptureManager) {
captureManager = newCaptureManager;
}
}
- (CaptureSessionManager *) captureManager {
if (captureManager != nil) {
return captureManager;
}
if ([[self parentViewController] isKindOfClass:[CameraContainerViewController class]]) {
CameraContainerViewController* parentView = (CameraContainerViewController*)[self parentViewController];
[self setCaptureManager:[parentView captureManager]];
}
return captureManager;
}
子级的
viewDidLoad
从父级的 addChildView
中的 content.view.frame = [self maxFrame]
调用(见上文: prepareForSegue
):
- (void) displayCameraPreview
{
CGRect layerRect = [[[self view] layer] bounds];
[[[self captureManager] previewLayer] setBounds:layerRect];
[[[self captureManager] previewLayer] setPosition:CGPointMake(CGRectGetMidX(layerRect),
CGRectGetMidY(layerRect))];
[[[self view] layer] addSublayer:[[self captureManager] previewLayer]];
}
- (void) initDisplay {
[self displayCameraPreview];
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
[self initDisplay];
}
请帮忙? :(
最佳答案
非常抱歉!
再次感谢上述教程的作者。干得好!
在拆分代码以设置不同的 View Controller 时,我忽略了一个小细节。应该开始 session ,不是吗?这是可以使用的来源:
- (void) displayCameraPreview
{
CGRect layerRect = [[[self view] layer] bounds];
[[[self captureManager] previewLayer] setBounds:layerRect];
[[[self captureManager] previewLayer] setPosition:CGPointMake(CGRectGetMidX(layerRect),
CGRectGetMidY(layerRect))];
[[[self view] layer] addSublayer:[[self captureManager] previewLayer]];
[[captureManager captureSession] startRunning];
}
关于ios - iPhone : Container View Controller and Camera Preview: preview is not displayed in child view controller,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15898261/
我在 Android 中使用相机时遇到问题。 在 API 25 Nougat 7.1.1 SDK 上进行开发。最小目标 SDK 设置为 15。 每次调用时都会抛出错误: Camera camera =
在我尝试过的所有手机上,包括带有 API 2.3.7 和 4.0 的 Galaxy Nexus,在调用 takePicture 方法后表面 View 更改为拍摄的图像,即“图像查看”。 我已经在这些平
我正在尝试在 Flutter 中的相机预览上显示 CustomPaint 元素。现在,CustomPaint 元素显示在相机预览下方。我正在使用 Flutter camera plugin显示相机预览
我有一个自定义相机应用程序,它在 SurfaceView 上预览相机视频输出并尝试拍照,照片应该由“xzing”扫描仪 API 处理以解码图像中的任何条形码。 我的应用程序预览正确并且没有抛出任何错误
我已经实现了使用 Android MediaRecorder 在后台录制音频,如果录音正在进行并且用户打开了 native 摄像头来录制视频,它会提供 Camera Error "Can't Conn
我在浏览相机脚本时遇到了声明术语 new Camera camera; 我想知道这是做什么的。它是在创建一个实例吗?让我感到困惑的是脚本已经附加到 Inspector 中的相机对象。那么为什么需要创建
我使用了我的 Fabric 服务,并在大多数运行我的应用程序的设备上发现了这个错误。 错误是这样的: Fatal Exception: java.lang.NullPointerException A
private static final int SENSOR_ORIENTATION_DEFAULT_DEGREES = 90; private static final int SENSOR_OR
我正在开发一个基本的自定义相机应用这些是我的依赖 // CameraX core library dependency implementation "androidx.camera:camera-c
我正在为索尼相机制作一个跟焦应用程序。我的应用程序需要能够设置焦点标记并调用它们。有很多功能可以在 Sony Camera API 上进行自动对焦,但我希望能够手动将焦点设置为给定的绝对值。有没有办法
我已经浏览了 Nest 开发人员网站,但找不到与相机相关的任何内容。我可以找到很多关于恒温器和烟雾/一氧化碳警报器的重要信息,但没有关于相机的信息。 特别是,我正在寻找如何获取视频 URL、如何获取/
关闭。这个问题需要details or clarity .它目前不接受答案。 想改进这个问题吗? 通过 editing this post 添加细节并澄清问题. 关闭 8 年前。 Improve t
我使用 create-react-native-app (CRNA) 创建了一个 RN 项目。我想使用expo提供的Camera API。为此,我只是复制了此处的示例 https://docs.exp
我想让我的相机跟随移动实体的第一人称视角。我不相信 trackedEntity 将适用于此用例,因为我不想查看实体,但我想查看 从它。我还希望用户能够使用鼠标相对于移动实体转动相机(例如,从移动平面的
我有一个跟进问题 Android Camera Server Died and Camera ERROR 100 我的代码中出现了类似的错误。这个错误出现在我们随机运行许多应用程序的自动化测试中。很长
我正在尝试实现与 Facebook 或 Instagram 相同的功能: 即时预览相机拍摄的图像 此时,调用此函数时,我的拍摄已正确拍摄: takePicture = async function()
我想给 React native Camera 添加水印。每当我点击/拍摄图像时,应该保存带有水印的图像。 最佳答案 我用了react-native-image-marker它对我有用。 关于reac
虽然索尼向客户挑逗新相机型号(UMC-R10C、UMC-S3C)并提到 API 访问和 USB 连接(而不是 wifi),但索尼相机远程 API 目前只提到 wifi。有没有关于如何使用这些即将推出的
我正在尝试使用以下代码在我的 xamarin android 应用程序中使用相机功能。 Intent intent = new Intent(MediaStore.ActionImageCapture
我构建了一个人脸检测应用程序,我从 onPreviewFrame 获取帧,进行人脸检测,然后在 surfaceView 上方的 Canvas 上绘制一个圆圈。问题是当 Camera.StartPrev
我是一名优秀的程序员,十分优秀!