Hope you’re having a great day.
I’m trying to build a simple page that navigates from one view to another, and I can’t get the NavigationLinks to work even when following existing examples/documentation precisely.
Here is the source view:
import SwiftUI
struct HomePageView: View {
var body: some View {
NavigationView{
Color.mint
.opacity(0.6)
.ignoresSafeArea()
.overlay{
VStack{
Text("SomeText")
.padding()
.font(Font.custom("Ubuntu-Title", size: 18))
}
}
NavigationLink(destination: DestinationView()){
Text("Navigate")
}
}
}
}
struct HomePageView_Previews: PreviewProvider {
static var previews: some View {
HomePageView()
}
}
And the destination view:
import SwiftUI
struct DestinationView: View {
var body: some View {
NavigationView{
Text("SomeText")
}
}
}
struct DestinationView_Previews: PreviewProvider {
static var previews: some View {
DestinationView()
}
}
It renders correctly in the preview, but nothing happens when I click the navigation button. I’ve read from other sources that NavigationLink is broken for WatchOS; are there any alternatives?
I’ve tried moving around the NavigationLink in the home view (before/after the Vstack, etc). Nothing has worked so far. This is pretty much the out of the box implementation for the NavigationLink, so I’m not sure where else to go. Thanks in advance for any ideas!
Isabella is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.