skip to Main Content

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 

2

Answers


  1. Chosen as BEST ANSWER

    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)
                    
                    
                    
                    
                    
                }
                }
                }
               }
             }
    

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

     NavigationLink(
             destination: Detailview_()
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search