XCode is throwing up the following constraint error when I attempt to use a UIStackView
:
(
"<NSAutoresizingMaskLayoutConstraint:0x7f87a1dfa360 h=--& v=--& V:[UIStackView:0x7f87a6403a00(0)]>",
"<NSLayoutConstraint:0x7f87a6410590 'UISV-canvas-connection' UIStackView:0x7f87a6403a00.top == UIView:0x7f87a6409630.top>",
"<NSLayoutConstraint:0x7f87a6444170 'UISV-canvas-connection' V:[UIView:0x7f87a644d790]-(0)-| (Names: '|':UIStackView:0x7f87a6403a00 )>",
"<NSLayoutConstraint:0x7f87a645bec0 'UISV-fill-equally' UIView:0x7f87a6407a10.height == UIView:0x7f87a6409630.height>",
"<NSLayoutConstraint:0x7f87a6458f40 'UISV-fill-equally' UIView:0x7f87a644d790.height == UIView:0x7f87a6409630.height>",
"<NSLayoutConstraint:0x7f87a64306d0 'UISV-spacing' V:[UIView:0x7f87a6409630]-(5)-[UIView:0x7f87a6407a10]>",
"<NSLayoutConstraint:0x7f87a643bea0 'UISV-spacing' V:[UIView:0x7f87a6407a10]-(5)-[UIView:0x7f87a644d790]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x7f87a643bea0 'UISV-spacing' V:[UIView:0x7f87a6407a10]-(5)-[UIView:0x7f87a644d790]>
My view controller is as follows:
public class ExampleController: UIViewController {
let v1 = UIView(frame: CGRect(x: 0, y: 0, width: 250, height: 100))
let v2 = UIView(frame: CGRect(x: 0, y: 0, width: 250, height: 300))
let v3 = UIView(frame: CGRect(x: 0, y: 0, width: 250, height: 200))
let parent1 = UIStackView()
public override func viewDidLoad() {
super.viewDidLoad()
v1.backgroundColor = .red
v2.backgroundColor = .green
v3.backgroundColor = .blue
parent1.axis = .vertical
parent1.distribution = .fillEqually
parent1.spacing = 5 // TODO: This causes the error!
parent1.addArrangedSubview(v1)
parent1.addArrangedSubview(v2)
parent1.addArrangedSubview(v3)
view.addSubview(parent1)
}
// MARK: Constraints
private var didUpdateConstraints = false
override public func updateViewConstraints() {
if !didUpdateConstraints {
parent1.snp.makeConstraints { (make) -> Void in
make.edges.equalToSuperview()
}
didUpdateConstraints = true
}
super.updateViewConstraints()
}
}
The distribution of the stack view doesn't seem to make a difference. Whenever spacing is set, I receive the error.
What is the conflict with my constraints?
What is
UISV-canvas-connection
?