For Example, This a view:
struct ContentA: View {
var body: some View {
Text(“Hello”)
}
}
struct ContentB: View {
var body: some View {
Button("Lets Go!") {
// Here i wanna to move to ContentA view
}
}
}
I want a way to reach the ContentA View by the button.
like this photo:Here
2
Answers
You can do this via this simple call to the specific view you want to reach . If you want to reach contentAView then just call it in the buttons action space like so
The easiest way to do this with SwiftUI is
NavigationLink
. I have tested this solution to work. You can also show a View as a Sheet. I’d look here for that solution. https://www.hackingwithswift.com/quick-start/swiftui/how-to-present-a-new-view-using-sheetsI believe the
NavigationLink
solution requires you to haveNavigationView
as well.