-2

I'm trying to implement a PresentationButton in SwiftUI. I keep getting the following error:

Missing argument for parameter #1 in call Insert '<#Label#>, '

I am using Xcode Version 11.0 beta.

This is my SwiftUI file:

import SwiftUI

struct HomeList : View {
    var body: some View {
        ScrollView(showsHorizontalIndicator: false) {
            HStack {
                ForEach(0 ..< 5/) { item in
                    PresentationButton(destination: ContentView()) {
                        CourseView()
                    }
                }
            }
        }
    }
}

#if DEBUG
struct HomeList_Previews : PreviewProvider {
    static var previews: some View {
        HomeList()
    }
}
#endif

struct CourseView : View {
    var body: some View {
        return VStack(alignment: .leading) {
            Text("Build an app with Swift UI")
                .font(.title)
                .fontWeight(.bold)
                .color(Color.white)
                .padding(20)
                .lineLimit(4)
                .frame(width: 120)

            Spacer()

            Image("Illustration1")
            }
            .background(Color("background3"))
            .cornerRadius(30)
            .frame(width: 246, height: 360)
            .shadow(color: Color("backgroundShadow3"), radius: 20, x: 0, y: 20)
    }
}
rmaddy
  • 314,917
  • 42
  • 532
  • 579
Billy Ruth
  • 95
  • 1
  • 1
  • 5
  • 2
    You're on beta 1? You should probably upgrade to the latest (beta 5), if you would like to get help here. A **lot** has changed. For once, PresentationButton has been deprecated and no longer available. – kontiki Jul 31 '19 at 06:08

2 Answers2

-1

As @kontiki stated, PresentationButton has been deprecated and no longer available.

A replacement that you could use is NavigationLink. This should work like PresentationButton. You will also need to change showsHorizontalIndicator: false to .horizontal, showsIndicators: false)

Also take out the / in your ForEach(0 ..< 5/). This could be another reason for your errors.

struct HomeList : View {
    var body: some View {
        ScrollView(.horizontal, showsIndicators: false) {
            HStack {
                ForEach(0 ..< 5) { item in
                    NavigationLink(destination: ContentView()) {
                        CourseView()
                    }
                }
            }
        }
    }
}

If you make these changes you should proceed error free. Good luck with the course: https://designcode.io/swiftui-course, I've enjoyed it. I'm not trying to plug it, just could see that he was following that tutorial.

Brett Holmes
  • 397
  • 5
  • 20
-1

After i used NavigationView combine with NavigationLink, it does worked

swiftUI PresentaionLink does not work second time

this worked for me

Michael Yang
  • 1,403
  • 2
  • 18
  • 27