Hello,
i had to found out, that I can’t call a view out of a ScrollView by tapping on an item of the scroll view. Enclosed minimal code show’s the effect. The tapping is recognized, but the view doesn’t switch to “AnotherView”.
Why is this the case? Works as designed or did I misunderstand something fundamental?
Any help appreciated.
Thx, Peter
import SwiftUI
struct ContentView: View {
var body: some View {
ScrollView{
VStack {
ForEach(0..<14) {value in
Text("Test \(value)")
.padding(.vertical)
.onTapGesture {
print("scrollview-item tapped")
AnotherView()
}
}
}
}
}
}
struct AnotherView: View {
var body: some View {
Text("Another View")
}
}
#Preview {
ContentView()
}
#Preview {
AnotherView()
}```