gpt4 book ai didi

iphone - 加载 View 层上方的 subview

转载 作者:行者123 更新时间:2023-12-01 19:23:59 25 4
gpt4 key购买 nike

我遵循了使用 AvFoundation Framework 拍照的教程。
所以我不精通它..这是一点。

在应用程序中..在 Nib 中。
有一个 View (SUBVIEW)作为主视图(MAINVIEW)的 subview 。
并且有一个 ImageView 和按钮作为 subview View (SUBVIEW)而不是主视图的 subview 。

教程中有代码(用于 subview )

AVCaptureVideoPreviewLayer *captureVideoPreviewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:session];


[self.vImagePreview.layer addSublayer:captureVideoPreviewLayer];

但是在应用这个之后, ImageView 出现在 SUBVIEW 的后面,而不是它应该在 Nib 中的前面。
那么如何让 ImageView 出现在 View 前面..vimagepreview 是 SUBVIEW

最佳答案

尝试以编程方式创建新 View ,添加图层,然后将 View 添加到 subview 。

AVCaptureVideoPreviewLayer *captureVideoPreviewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:session];
UIView *newView = [[UIView alloc] initWithFrame:SUBVIEW.bounds];
[newView.layer addSublayer: captureVideoPreviewLayer];
[SUBVIEW addSubview: newView];

那应该确保该层位于 subview 之上。

关于iphone - 加载 View 层上方的 subview ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8854872/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com