I had a problem with my app (or in my setup) and searching the web I found a very simple code where part of my problem occurs.
I create a new Multiplatform App and
paste this code in ContentView.
import SwiftUI
struct ContentView: View {
var body: some View {
NavigationStack {
VStack {
Text("Navigation article")
.font(.title)
.padding()
NavigationLink("Go to the second view", destination: SecondView())
.padding()
}
.navigationTitle("First View")
}
}
}
struct SecondView: View {
var body: some View {
Text("This is the Second view")
.font(.headline)
.padding()
.navigationTitle("Second View")
}
}
run on iPhone/ iOS no problem
run on a Mac/macOS
Going from view 1 to view 2 work, the back arrow on view 2 is there, and it is working but the second time I go to the view 2, the back arrow is gone.
after looking closely I can see the Arrow Underneath the S of SecondView.
I have tried many things and could not make it work.
I post this in a HackingWithSwift forum and somebody tried the code and said it work. so it seems the problem could be related to my setup but I create another user in my computer , same problem and tried it on my another computer, same problem.
Topic:
UI Frameworks
SubTopic:
SwiftUI