Back menu Item not displaying or working

Hello all

My first SwiftUI program..and I have to say I'm not really impressed with this...

Issue is when I open the second View, the blue "< Back" menu item never shows up.


I have a NavigationLink to open a seperate View.

Yet when the secondary view opens, the "< Back" menu item never displays.

From ContentView.swift:

HStack {

NavigationLink(destination: DetailView()) {

Text("Summary")

}.navigationBarTitle(" ").navigationBarHidden(false)


From the DetailView.swift file:

var body: some View {

NavigationView {

Group {

VStack {

Text("Detail View")

}

}

}.navigationBarHidden(false).navigationBarBackButtonHidden(false)

}


I have been fighting with this for over 12 hours now. Quite frankly it is giving me the impression that SwiftUI is not worth the time or effort, and it is not designed to work at all. As this was something that could be done with storyboards in 20 minutes. This is extremely frustrating.

So any help at this point would be appreciated.

Accepted Reply

It looks like your content view isn't wrapped in a NavigationView, only the detail. That won't work, it's like a parent/detail relationship.


ContentView.swift:

var body: some View {

NavigationView {
     HStack {
          NavigationLink(destination: DetailView()) {
               Text("Summary")
          }
     }
}

}


From the DetailView.swift file (remove the second navigation view):

var body: some View {

VStack {
     Text("Detail View")
}

}

Replies

Thanks for the suggestion and help.

Really do appreciate it as this has gotten extremely frustrating compared to using storyboards.

I did figure it out. I used the example from youtube:

https://www.youtube.com/watch?v=bqr5NidImk0

and that seemed to work on my phone (still something wrong with the simulator.)


I'm now on to the point where I'm trying to share data bewtween the 2 views...

needless to say this is another very NEGATIVE experianece. In story board I could get this whole app done in an hour.

now I'm fighting with the most basic of things like global variables not working or printing or updating correctly.

to be quite blunt, I think swift UI is straight garbage. and it's a good thing for the people that developed this that Steve Jobs isn't around anymore. Otherwise they would get fired for incompetence (and rightfully so). I and customers don't have time (or the money to pay for that time) to fight with things and deal with 50 steps for something that should take 1 step.

Either way, sorry to vent at you and I do appreciate your suggestion and help.

It looks like your content view isn't wrapped in a NavigationView, only the detail. That won't work, it's like a parent/detail relationship.


ContentView.swift:

var body: some View {

NavigationView {
     HStack {
          NavigationLink(destination: DetailView()) {
               Text("Summary")
          }
     }
}

}


From the DetailView.swift file (remove the second navigation view):

var body: some View {

VStack {
     Text("Detail View")
}

}