0

as the title says I am trying to add a Text("xyz") field inside a VStack inside a Navigation View. I already have a a few navigation links and some other text but when I try adding another Text field I get the error: "Extra arguments at positions #11, #12 in call".

Is there a limit to the number of fields within a view or within a stack? If I take out the Text field it works fine. The text field seems to make another Link I have further down become the issue.

Here is what I currently have which currently throws an error for the link at the bottom, if I add another text field I get an error for the banner at the top (this latter case is the one shown below)

import SwiftUI

struct HomePage2: View {
    var body: some View {
        NavigationView {
            VStack {
                BannerImage(image: Image("placeholderHouse"))
                    .ignoresSafeArea(edges: .top)
                
                NavigationLink(destination: HouseList()) {
                        Text("About this app")
                }.buttonStyle(GradientButtonStyle())
                
                Text("Find out how we can help you carry out your own survey.")
                    .font(.caption)
                    .fontWeight(.thin)
                
                NavigationLink(destination: HouseList()) {
                        Text("New")
                }.buttonStyle(GradientButtonStyle())

                Text("Find out how we can help you.")
                    .font(.caption)
                    .fontWeight(.thin)
                
                NavigationLink(destination: HouseList()) {
                        Text("View")
                }.buttonStyle(GradientButtonStyle())
                
                Text("Find out more.")
                    .font(.caption)
                    .fontWeight(.thin)
                
                NavigationLink(destination: HouseList()) {
                        Text("View Disclaimer")
                }.buttonStyle(GradientButtonStyle())
                Spacer()
                Text("informationtextblahblahblah")
                    .font(.caption)
                    .fontWeight(.thin)
                    .multilineTextAlignment(.center)
                Text("If you have any feedback, suggestions or issues please contact us at:")
                    .foregroundColor(Color.gray)
                    .multilineTextAlignment(.center)
                Link("abc@icloud.com", destination: URL(string: "mailto:abc@icloud.com")!)
            }
        }
    }
}


struct GradientButtonStyle2: ButtonStyle {
    func makeBody(configuration: Self.Configuration) -> some View {
        configuration.label
            .foregroundColor(Color.white)
            .padding()
            .background(LinearGradient(gradient: Gradient(colors: [Color.red, Color.orange]), startPoint: .leading, endPoint: .trailing))
            .cornerRadius(15.0)
            .shadow(radius: 5)
    }
}

struct HomePage2_Previews: PreviewProvider {
    static var previews: some View {
        HomePage2()
    }
}
  • you cannot add more than 10 view inside VStack manually ( can be done using FoarEach) , as a solution you can put your view inside Group{} within in VStack – YodagamaHeshan Jan 06 '21 at 09:30
  • I am also getting preview crashed when I try to preview and click one of the links on the page. Any ideas? – Liam Rothwell Jan 06 '21 at 09:35

0 Answers0