Home > Blockchain >  Simple SwiftUI Application
Simple SwiftUI Application

Time:10-01

So my swift code is doing the task that I want it to by creating a list, and my users are able to click onto that list that takes them to the 2nd screen but it isn't taking me to the destination that I want it to go to which is "DetailView" and then to "SectionView . I was following along with a youtube video but they used a NavigationButton to do this and that has been depreciated. I have linked the youtube video here: https://youtu.be/Pfw7zWxchQc

This is my Code that is correct but its not NavigationLink to my DetailView page.

            import SwiftUI

              struct ContentView: View {
              var body: some View {
               NavigationView {
               List {
                 ForEach(model) { Model in
                
                     NavigationLink(
                       destination: Text ("Detailview_(codeName: ,1"),
                      label: {
                        Text("Model  \( "1")")
                            .padding()
                       })
            }
            }
          }
         }
        }
     
        
 





If anyone can help that would be much appreciated! I've been trying to figure this out for like 24h 

CodePudding user response:

Your destinationview is a Text : Text ("Detailview_(codeName: ,1") Try with

 NavigationLink(
         destination: Detailview_()

CodePudding user response:

The solution to this issue is below. I wasn't setting my NavigationLink's destination correctly but after may tries and some help, this works correctly. Thank you to those that helped!

       NavigationView {
        VStack {
        List {
            ForEach(model) { Model in
                NavigationLink("Model", destination: 
          Detailview_(codeName: Model.codeName))
                SelectionView(codeName:
                                Model
                                .codeName)
                
                
                
                
                
            }
            }
            }
           }
         }
  • Related