Environment: Xcode Version 12.4 (12D4e)
Scenario: I found one area that apparently has constraint violations.
I narrowed it down to the .navigationTitle.
import SwiftUI
struct ContentView: View {
var body: some View {
NavigationView {
VStack {
Text("Hello World")
}.navigationTitle("Turkey")
}
}
}
That's it.
If I remove the .navigationTitle(), it clears up.
Here's are the constraint violation(s) listed in the console:
2021-02-09 19:14:38.578190-0800 NavBarCheck[6300:437683] [LayoutConstraints] 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:0x600003149ef0 'BIB_Trailing_CB_Leading' H:[_UIModernBarButton:0x12c01a770]-(6)-[_UIModernBarButton:0x12c0191e0'Turkey'] (active)>",
"<NSLayoutConstraint:0x600003149f40 'CB_Trailing_Trailing' _UIModernBarButton:0x12c0191e0'Turkey'.trailing <= _UIButtonBarButton:0x12c018560.trailing (active)>",
"<NSLayoutConstraint:0x60000314acb0 'UINav_static_button_horiz_position' _UIModernBarButton:0x12c01a770.leading == UILayoutGuide:0x600002b65260'UIViewLayoutMarginsGuide'.leading (active)>",
"<NSLayoutConstraint:0x60000314ad00 'UINavItemContentGuide-leading' H:[_UIButtonBarButton:0x12c018560]-(0)-[UILayoutGuide:0x600002b65180'UINavigationBarItemContentLayoutGuide'] (active)>",
"<NSLayoutConstraint:0x60000314c780 'UINavItemContentGuide-trailing' UILayoutGuide:0x600002b65180'UINavigationBarItemContentLayoutGuide'.trailing == _UINavigationBarContentView:0x12ae0f100.trailing (active)>",
"<NSLayoutConstraint:0x60000314b3e0 'UIView-Encapsulated-Layout-Width' _UINavigationBarContentView:0x12ae0f100.width == 0 (active)>",
"<NSLayoutConstraint:0x60000314cb40 'UIView-leftMargin-guide-constraint' H:|-(0)-[UILayoutGuide:0x600002b65260'UIViewLayoutMarginsGuide'](LTR) (active, names: '|':_UINavigationBarContentView:0x12ae0f100 )>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x600003149ef0 'BIB_Trailing_CB_Leading' H:[_UIModernBarButton:0x12c01a770]-(6)-[_UIModernBarButton:0x12c0191e0'Turkey'] (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.
Question: Is this a bug? or if not, what's happening and remedy?