Reputation: 2017
I have the following:
ScrollView(.horizontal, showsIndicators: false) {
HStack {
ForEach(events) { event in
VStack {
Image(event.image)
.resizable()
.aspectRatio(contentMode: .fill)
.frame(width: 100, height: 100)
.padding(55)
NavigationLink(destination: PostView()) {
Text(event.name)
.font(.system(.headline))
.padding(.bottom,20)
}
}
.padding()
.border(Color.black, width: 4)
.cornerRadius(10)
}
}
}
But the NavigationLink NavigationLink(destination: PostView()) {
doesn't take me to the correct view?
Ii have tried wrapping the NavigationLink around the each VStack but that also doesn't take me to the view
Upvotes: 0
Views: 84
Reputation: 451
I think is you don't have using "NavigationView".
NavigationView{
ScrollView(.horizontal, showsIndicators: false) {
HStack {
ForEach((1...10).reversed(), id: \.self) {_ in
VStack {
NavigationLink(destination: PostView()) {
Text("event.name")
.font(.system(.headline))
.padding(.bottom,20)
}
}
.padding()
.border(Color.black, width: 4)
.cornerRadius(10)
}
}
}
}
Upvotes: 1