Swiftui Navigationview Navigationbartitle Layoutconstraints Issue

SwiftUI NavigationView navigationBarTitle LayoutConstraints issue

NavigationBarTitle is deprecated from iOS 14.3.
However if you still wish to use it, try to add
.navigationViewStyle(StackNavigationViewStyle()) on the navigationView
that will fix the warning.

       struct ContentView: View {
var body: some View {
NavigationView {
VStack {
Text("Hello, world!")
.padding()
Spacer()
}
.navigationBarTitle("Hey there", displayMode: .inline)
}
.navigationViewStyle(StackNavigationViewStyle())
}
}

The new way:

.navigationBarTitleDisplayMode(.inline)
.toolbar(content: {
ToolbarItem(placement: .principal, content: {
Text("Title")
})})

swiftui - how to avoid 'Unable to simultaneously satisfy constraints' error?

Let's look at these one by one:

This is saying view 0x7fde585064a0 is active and has 44 points height

This is saying that 0x7fde585064a0's top edge must be a gap of 0 points from the top of its superview 0x7fde58518070

This is saying view 0x7fde51b78c50 and 0x7fde585064a0 are conflicting. These four things can't all be true. And the problem with constraints 0x600002591b30. Find out where the problem is and set true constraint.

I think it's useful to know the basics and understand what Apple / Xcode is trying to tell you via logs:

H = Horizontal constraint(for leading and Trailing)
V = Vertical constraint(top and bottom edge)
h = height
w = width

TopEdge -> V:|-(points)-[VIEW:memoryAddress]
BottomEdge -> V:[VIEW:memoryAddress]-(points)-|
Leading -> H:|-(points)-[VIEW:memoryAddress]
Trailing -> H:[VIEW:memoryAddress] -(points)-|
height -> h= --& v=--& V:[VIEW:memoryAddress((points)]
width -> VIEW:memoryAddress.width == points
between -> H:[VIEW 1]-(51)-[VIEW 2]


Related Topics



Leave a reply



Submit