UIButton disappears when I add AVCaptureVideoPreviewLayer to my UIView

I added a view to my view manager and added a record button to my view in the interface builder. Programmatically, I initialize the layer AVCaptureVideoPreviewand add it to mine view.layer. When I run in, I see that the camera is working on my screen, but there is no button. I have to add a button using [myView addSubview:self.record], then I see it. I checked my interface constructor and the button is opaque, but it does not appear until I add it to the code.

Any thoughts ???

Your help is greatly appreciated.

+4
source share
2 answers

, AVCaptureVideoPreviewLayer, , viewDidLoad , IB , UIButton - ( /). AVCaptureVideoPreviewLayer . . , .

AVCaptureVideoPreviewLayer *captureVideoPreviewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:session];
[self.containerView.layer addSublayer:captureVideoPreviewLayer];

:

view hierarchy

+4

layer.insertSublayer(..., :...), .

Swift,

0

Source: https://habr.com/ru/post/1533828/


All Articles