SwiftUI NavigationButton without the disclosure indicator?

前端 未结 16 840
不知归路
不知归路 2020-12-02 12:04

When making a List with a row that pushes to a new view, SwiftUI adds a disclosure indicator \">\" automatically? How do I remove it if I don\'t want it?

            


        
相关标签:
16条回答
  • 2020-12-02 12:56

    Once you put your button in a scrollview, the disclosure button will be hidden. Just make sure to disable your scroll indicator.

    0 讨论(0)
  • 2020-12-02 12:57

    Setting the NavigationLink width and hiding it did the trick for me

    List {
      ForEach(pages) { page in
        HStack {
          Text("Something")
    
          NavigationLink(destination: Text("Somewhere")) {
            EmptyView()
          }
          .frame(width: 0)
          .opacity(0)
        }
      }
    }
    
    0 讨论(0)
  • 2020-12-02 13:01

    This helps to push and pass the model to the next navigation view controller.

    struct ContentView : View {
        @State var model = PostListViewModel()
    
        var body: some View {
            NavigationView {
                List(model.post) { post in
                    ListCell(listData: post)
                    }.navigationBarTitle(Text("My Post"))
            }
        }
    
    }
    
    struct ListCell: View {
        var listData: Post
        var body: some View {
            return NavigationButton(destination: DetailContentView(post: listData)) {
                HStack {
                    ImageRow(model: listData) // Get image
                    VStack(alignment: .leading) {
                        Text(listData.login).font(.headline).lineLimit(nil)
                        Text(listData.url).font(.subheadline).lineLimit(nil)
                        }.padding(.leading, 10)
                    }.padding(.init(top: 5, leading: 0, bottom: 5, trailing: 0))
            }
        }
    }
    
    0 讨论(0)
  • 2020-12-02 13:03

    The easiest one. The content for each item in the list.

    ZStack {
       NavigationLink(destination: DetailView()) {
           EmptyView()
       }.hidden()
       RowView()
    }
    
    0 讨论(0)
提交回复
热议问题