-
Notifications
You must be signed in to change notification settings - Fork 5
Description
Something wrong with UIStackView inside UIViewAdaptor, but I can't figure out what exactly. I tried to use different flexibility, idealSizeCalculator but still got this errors in console:
Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want.
Try this:
(1) look at each constraint and try to figure out which you don't expect;
(2) find the code that added the unwanted constraint or constraints and fix it.
(
"<NSLayoutConstraint:0x28241fed0 UIView:0x13dd10ce0.height == 100 (active)>",
"<NSLayoutConstraint:0x28241fb60 'UISV-alignment' UIView:0x13dd0ec50.bottom == UIView:0x13dd10ce0.bottom (active)>",
"<NSLayoutConstraint:0x28241fb10 'UISV-alignment' UIView:0x13dd0ec50.top == UIView:0x13dd10ce0.top (active)>",
"<NSLayoutConstraint:0x28241fc00 'UISV-canvas-connection' UIStackView:0x13dd10950.top == UIView:0x13dd0ec50.top (active)>",
"<NSLayoutConstraint:0x28241fbb0 'UISV-canvas-connection' V:[UIView:0x13dd0ec50]-(0)-| (active, names: '|':UIStackView:0x13dd10950 )>",
"<NSLayoutConstraint:0x28241f610 'UIView-Encapsulated-Layout-Height' UIStackView:0x13dd10950.height == 711 (active)>"
)Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x28241fed0 UIView:0x13dd10ce0.height == 100 (active)>Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.
var body: some View {
VStack {
UIViewAdaptor {
let stack = UIStackView()
let firstView = UIView()
firstView.backgroundColor = .red
let secondView = UIView()
secondView.backgroundColor = .blue
[firstView, secondView].forEach {
$0.translatesAutoresizingMaskIntoConstraints = false
}
NSLayoutConstraint.activate([
firstView.heightAnchor.constraint(equalToConstant: 100),
secondView.heightAnchor.constraint(equalToConstant: 100)
])
stack.addArrangedSubview(firstView)
stack.addArrangedSubview(secondView)
return stack
}
Spacer()
}
}