Learn Courses My Dashboard

Module 2 Lesson 15 Recipe App Question

Hi there

As I was developing my own app, I noticed that I seem to get a lot of messages like:

[LayoutConstraints] Unable to simultaneously satisfy constraints.

I determined that this was caused by the .navigationBarTitle(“All Recipes”) attached to a List. I went and had a look at Chris’s M2L15 Recipe app, and saw that the Debug Console gives the same error.

Can anyone explain to me why this is and what I should do or do differently?

Regards
Hannes

This is a SwiftUI bug. It happens to me.

Don’t worry about it

Adding the .navigationViewStyle(StackNavigationViewStyle()) modifier to the navigationView { } fixes the 'LayoutConstraints" console errors…

 NavigationView {
        List(model.recipes) { r in
            // Link row item to RecipeDetailView
            NavigationLink(
                destination:(RecipeDetailView(recipe:r)),
                label: {
                    // MARK: Row Item
                    HStack(spacing: 20.0) {
                        Image(r.image)
                            .resizable()
                            .scaledToFill()
                            .frame(width: 50, height: 50, alignment: .center)
                            .clipped()
                            .cornerRadius(5.0
                            )
                        Text(r.name)
                    }
                })
        }
        .navigationBarTitle(Text("All Recipes")) // List Title
    }
    .navigationViewStyle(StackNavigationViewStyle())

StackOverflow fix

Dev Docs…