我正在掃描條形碼iOS應用使用AVFoundationAVfoundation相機熄滅屏幕的OBJ-C
所以我創建使用接口建設者約束方盒子。方盒與約束條件都很好。非常好。 我有以下代碼將avcapturelayer添加到方框中。
self.captureLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:self.captureSession];
[self.captureLayer setFrame:self.cameraPreviewView.layer.bounds];
[self.captureLayer setVideoGravity:AVLayerVideoGravityResizeAspectFill];
[self.cameraPreviewView.layer addSublayer:self.captureLayer];
該圖層遵循方框約束的前導空間,但不跟蹤尾部。新添加的AVlayer會在屏幕上向右(右側),而方形盒本身都很好。我在這裏錯過了什麼?
謝謝!