Home > Net >  Swift navigation view not navigating to new page
Swift navigation view not navigating to new page

Time:01-23

I'm using navigation view to navigate to a new page this is my code below which is not helping to naviate to the next page

LazyVGrid(columns: columns, spacing: 20) {
    ForEach( model.car, id: \.self) { item in
        NavigationLink(destination: CarDetailedView(carName: item.name, carImage: item.image)) {
            VStack{
                GridImageView(item.image,item.name)
                Text(item.name)
            }
        }
    }
}

CodePudding user response:

Try this:

NavigationStack {
    LazyVGrid(columns: columns, spacing: 20) {
        ForEach( model.car, id: \.self) { item in
            NavigationLink {
                CarDetailedView(carName: item.name, carImage: item.image)
            } label: {
                VStack{
                    GridImageView(item.image,item.name)
                    Text(item.name)
                }
            }

                    
        }
    }
}
  • Related