Missing argument for parameter 'images' in call

Dear All Hope some one can help me... Xcode Shows me 4 Elements to fix it... I will that the user tapped on one Card and goes to that Category. What is my fails ? I know that I have struggle whit the NavigationLink... Hope you can help me out please . Have a nice Weekend....

import SwiftUI

struct ContentView: View {

    func Images(_ images : Images){}

    var columns = [GridItem(.adaptive(minimum: 170), spacing: 20)]

    var body: some View {

        NavigationView {

            ScrollView {

                LazyVGrid(columns: columns, spacing: 10) {

                    ForEach(ImagesList, id: .id) {images in

                        ImageCard(images: images)

                        

                        NavigationLink {LandCard()} label: { ImageCard() })

                    }

                }

                .padding(10)

            }

            .navigationTitle(Text("Bilder"))

        }

        .navigationViewStyle(StackNavigationViewStyle())

    }

}

struct ContentView_Previews: PreviewProvider {

    static var previews: some View {

        ContentView()

    }

}

Answered by BabyJ in 721249022

Thank you for sharing all the code.

The probable cause of your height issue is that you have wrapped the contents of your ImageCard body in a NavigationView. You don't need to do this as you are already embedding it in one in ContentView.

Remove the NavigationView from ImageCard to see if this helps.

If it doesn't help, which I'm sure it will, then it would be down to the fact that you are setting an explicit height of 200 to the ZStack in ImageCard. I'm not sure how much this affects things but changing this value to a smaller one might make a difference.

Missing argument for parameter 'images' in call

The problem you have is the ImageCard view has an images parameter that you haven't specified in the NavigationLink label.

Consecutive statements on a line must be separated by ';'

You also have a closing parenthesis after the NavigationLink which has no matching opening parenthesis; this triggers a syntax error.


Replace the contents of your ForEach with this:

NavigationLink {
    LandCard()
} label: {
    ImageCard(images: images)
}

Vielen Dank, das war eine schnelle Antwort. Schön... Das nächste "Problem" ist also, dass die Karten doppelt so hoch sind... (Siehe Anhang) Meine Frage ist also, wie kann ich das beheben?

Und das nächste ist. Ich werde tun, dass ich auf LandCard getippt habe, es wird zu LandView gehen. Das Gleiche gilt für Maritimes. Ich werde auf die MaritimesCard tippen, es wird zu MaritimesView gehen.

Ich weiß, dass das so weitergehen muss, aber tut mir leid, ich bin neu bei Swift Ui ;)

Vielen Dank für Ihre Hilfe...

Sorry if I didn't make this clear, but your code from before should look like this:

ForEach(ImagesList, id: \.id) { images in
    NavigationLink {
        LandCard()
    } label: {
        ImageCard(images: images)
    }
}

Currently you are showing the ImageCard view twice, the second as a NavigationLink, but I assume that you only need it once.


On your second problem, the height of the ImageCard depends on how you create it. Can you show the code for the ImageCard view so that we can understand what is causing the issue?

Have a lot of thanks.... Of Course. Here ist Code for ImageCard....

import Swift UI
struct ImageCard: View {

    var images: Images

    var body: some View {
        NavigationView{
            ZStack(alignment: .bottom) {
                Image(images.image)
                    .resizable()
                    .cornerRadius(18)
                    .frame(width: 200)
                    .scaledToFit()
                VStack(alignment: .leading)
                Text("\(images.category)")
                    .frame(width: 200, height: 40, alignment: .center )
                    .background(.ultraThinMaterial)
                    .cornerRadius(18)
                    .bold()
            }
            .frame(width: 200, height: 200)
            .shadow(radius: 3)

        }

    }

}
struct ImageCard_Previews: PreviewProvider {
    static var previews: some View {
        ImageCard(images: ImagesList[0])
    }
}

And here is the Code of my model

import Foundation

struct Images: Identifiable {

    var id = UUID()
    var name: String
    var category: String
    var image: String
}

var ImagesList = [Images(name: "Steinkirchen", category: "Landschaften", image: "Uebersicht_1"),
                 Images(name: "Seacloud-Spirit",category: "Maritimes", image: "Uebersicht_2"),
                 Images(name: "Grashalm", category: "Natur", image: "Uebersicht_3"),
                 Images(name: "Details", category: "Projekte", image: "Uebersicht_4"),
                 Images(name: "Festmacher", category: "Schwarz/Weiß",  image: "Uebersicht_5")
]

struct Land: Identifiable {

    var id = UUID()
    var name: String
    var category: String
    var image: String

}

var LandList = [Images(name: "Helgoland", category: "Die Lange Anna", image: "Landschaften_1"),
                Images(name: "Thunersee",category: "Thunersee/Schweiz", image: "Landschaften_2"),
                Images(name: "Steinkirchen", category: "Das Alte Land", image: "Landschaften_3"),
                Images(name: "Steinkirchen", category: "Das Alte Land", image: "Landschaften_4"),
                Images(name: "Thunersee", category: "Thunersee/Schweiz", image: "Landschaften_5"),
                Images(name: "Steinkirchen", category: "Das Alte Land", image: "Landschaften_6")
]

struct Maritimes: Identifiable {

    var id = UUID()
    var name: String
    var category: String
    var image: String

}



var MaritimesList = [Images(name: "Amerigo Vespucci", category: "3-Master", image: "Maritimes_1"),

                Images(name: "Festmacher",category: "Festmacher", image: "Maritimes_2"),
                Images(name: "Hapag", category: "Containerschiff", image: "Maritimes_3"),
                Images(name: "Fischkutter", category: "Kutter", image: "Maritimes_4"),
                Images(name: "Festmacher", category: "Festmacher", image: "Maritimes_5"),
                Images(name: "Seacloud-Spirit", category: "3-Master", image: "Maritimes_6")
]

And there will be all correct, here is the code for

import SwiftUI
struct ContentView: View {

    var columns = [GridItem(.adaptive(minimum: 160), spacing: 5)]

    var body: some View {
        NavigationView {
            ScrollView {
                LazyVGrid(columns: columns) {
                    ForEach(ImagesList, id: \.id) { images in
                        NavigationLink {
                            LandCard()
                        } label: {
                            ImageCard(images: images)
                        }
                    }
                }
                .padding(10)
            }
            .navigationBarTitle(Text("Übersicht"))
        }
        .navigationViewStyle(StackNavigationViewStyle())
    }
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}

Have so many thanks, for helping me on this weekend... Greeting from Germany

Accepted Answer

Thank you for sharing all the code.

The probable cause of your height issue is that you have wrapped the contents of your ImageCard body in a NavigationView. You don't need to do this as you are already embedding it in one in ContentView.

Remove the NavigationView from ImageCard to see if this helps.

If it doesn't help, which I'm sure it will, then it would be down to the fact that you are setting an explicit height of 200 to the ZStack in ImageCard. I'm not sure how much this affects things but changing this value to a smaller one might make a difference.

Thanks so much, your first works great for me... But, how can I do the next step ? When I tapped on Landschaften that will be shows me Landschaften... That's nice. How can I do it for Maritimes? When I Tapped on Maritimes then I will that shows me Maritimes images... Can I drop more NavigationLinks in ContentView ?

Have many Thanks ;)

import SwiftUI
struct ContentView: View {

    var columns = [GridItem(.adaptive(minimum: 160), spacing: 5)]

    var body: some View {
        NavigationView {
            ScrollView {
                LazyVGrid(columns: columns) {
                    ForEach(ImagesList, id: \.id) { images in
                        NavigationLink {
                            LandView()
                        } label: {
                            ImageCard(images: images)
                        }
                    }
                }
                .padding(10)
            }
            .navigationBarTitle(Text("Übersicht"))
        }
        .navigationViewStyle(StackNavigationViewStyle())
    }
}

struct ContentView_Previews: PreviewProvider {

    static var previews: some View {
        ContentView()
    }
}
Missing argument for parameter 'images' in call
 
 
Q