4

When using a NavigationView to link to a Detail View from a List, SwiftUI automatically adds a > detail/disclosure indicator to the right side of the List view row. The > and the padding around it are causing issues with my layout which I would like to extend all the way to the end of the row. How can I remove the disclosure indicator?

The same question was asked here SwiftUI NavigationButton without the disclosure indicator? but at the time, there was no solution, only work arounds that don't work so well.

Is there a solution to this problem yet, or is it a matter of waiting for SwiftUI to be updated?

Screenshot of the Issue:

ThanhPhanLe
  • 1,315
  • 3
  • 14
  • 25
lmh
  • 293
  • 1
  • 4
  • 13
  • We have to wait. There isn't yet a "real" solution with List. – Giuseppe Sapienza Aug 24 '19 at 09:21
  • 1
    Possible duplicate of [SwiftUI NavigationButton without the disclosure indicator?](https://stackoverflow.com/questions/56516333/swiftui-navigationbutton-without-the-disclosure-indicator) – Giuseppe Sapienza Aug 24 '19 at 09:21
  • I updated the duplicate question with a new answer that works with beta 6: https://stackoverflow.com/a/57636908/7786555 – kontiki Aug 24 '19 at 10:03
  • @kontiki: Thanks, that's an interesting workaround. It'll work for now! – lmh Aug 31 '19 at 05:54
  • UPDATE: I'm now using a ZStack as suggested in this answer and it seems to be working a bit better: https://stackoverflow.com/a/58426294/11925891. I will note that I had to remove the .buttonStyle(PlainButtonStyle()) as my code would not compile with it. No idea why, but hey, that's SwiftUI right now! – lmh Nov 13 '19 at 01:11

1 Answers1

1

iOS13 , iOS 14

List { 
    ForEach(items) { item in
        ZStack {
            CustomView(item: item)
            NavigationLink(destination: anotherView()) {
                EmptyView()
            }
              .opacity(0)
              .buttonStyle(PlainButtonStyle())
        }
    }
}
Behzad Moulodi
  • 147
  • 2
  • 11