Вы добавили ограничения, прикрепляющие capturePreview
к cameraView
?Вам нужно будет сделать это в коде.Добавьте ограничения, чтобы левый, правый, верхний и нижний края capturePreview
были присоединены к соответствующим ребрам cameraView
.
Цель C
NSLayoutConstraint *topConstraint = [NSLayoutConstraint constraintWithItem:capturePreview attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:cameraView attribute:NSLayoutAttributeTop multiplier:1.0 constant:0.0];
NSLayoutConstraint *leftConstraint = [NSLayoutConstraint constraintWithItem:capturePreview attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:cameraView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0.0];
NSLayoutConstraint *rightConstraint = [NSLayoutConstraint constraintWithItem:capturePreview attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:cameraView attribute:NSLayoutAttributeRight multiplier:1.0 constant:0.0];
NSLayoutConstraint *bottomConstraint = [NSLayoutConstraint constraintWithItem:capturePreview attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:cameraView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0.0];
[NSLayoutConstraint activateConstraints:@[topConstraint, bottomConstraint, leftConstraint, rightConstraint]];
Свифт
let topConstraint = NSLayoutConstraint(item: capturePreview, attribute: .top, relatedBy: .equal, toItem: cameraView, attribute: .top, multiplier: 1.0, constant: 0.0)
let bottomConstraint = NSLayoutConstraint(item: capturePreview, attribute: .bottom, relatedBy: .equal, toItem: cameraView, attribute: .bottom, multiplier: 1.0, constant: 0.0)
let leftConstraint = NSLayoutConstraint(item: capturePreview, attribute: .left, relatedBy: .equal, toItem: cameraView, attribute: .left, multiplier: 1.0, constant: 0.0)
let rightConstraint = NSLayoutConstraint(item: capturePreview, attribute: .right, relatedBy: .equal, toItem: cameraView, attribute: .right, multiplier: 1.0, constant: 0.0)
NSLayoutConstraint.activate([topConstraint, bottomConstraint, leftConstraint, rightConstraint])