title: SwiftUI NavigationView, going back if NavigationLink is inside a NavigationBarItem
body: <p>As there are some problems with iOS 13.4 and Xcode 11.4 with <code>presentationMode.wrappedValue.dismiss()</code> I am looking for an alternative approach to go back programmatically. I found this solution from MScottWaller:</p>
  
  <p><a href="https://stackoverflow.com/questions/56513568/ios-swiftui-pop-or-dismiss-view-programmatically">iOS SwiftUI: pop or dismiss view programmatically</a></p>
  
  <p>Unfortunately, in my case it does not work:</p>
  
  <pre class="lang-swift prettyprint-override"><code>struct MasterView: View {
      @State private var showDetail = false
  
      var body: some View {
          VStack {
              Text("MasterView")
              .navigationBarItems(trailing: HStack {
                  NavigationLink(destination: DetailView(showSelf: $showDetail), isActive: $showDetail) {
                      Image(systemName: "tag")
                          .padding(.leading, 4)
                  }
              })
          }
      }
  }
  
  struct DetailView: View {
      @Binding var showSelf: Bool
  
      var body: some View {
          Button(action: {
              self.showSelf = false
          }) {
              Text("Pop")
          }
      }
  }
  </code></pre>
  
  <p>If the NavigationLink is inside a navigationBarItem, I can't go back from my DetailView. I don't know if it is a bug or there are other reasons why NavigationLink does not work in the same way inside a navigationBarItem.</p>
  
  <p>As a workaround I use this variant with a empty NavigationLink inside the view. It works, but I don't like this:</p>
  
  <pre class="lang-swift prettyprint-override"><code>struct MasterView: View {
      @State private var showDetail = false
  
      var body: some View {
          VStack {
              Text("MasterView")
              NavigationLink(destination: DetailView(showSelf: $showDetail), isActive: $showDetail) {
                  EmptyView()
              }
              .navigationBarItems(trailing: HStack {
                  Button(action: { self.showDetail.toggle() }) {
                      Image(systemName: "tag")
                          .padding(.leading, 4)
                  }
              })
          }
      }
  }
  </code></pre>
  
  <p>Any ideas why the NavigationLink does not correct work inside a navigationBarItem?</p>