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?
NavigationView { List { NavigationButton(destination: DetailView()) { ListItem() } } .navigationBarTitle(Text("Some title")) }
On a UITableViewCell you set Accessory to None but how do I do that in SwiftUI?
For the navigation link, instead of presenting the Text view, we change it to display an empty view. And, we attach the opacity modifier to NavigationLink and set its value to 0 . If you test the change in the preview, the disclosure indicator should disappear.
SwiftUI's NavigationLink has a second initializer that has an isActive parameter, allowing us to read or write whether the navigation link is currently active. In practical terms, this means we can programmatically trigger the activation of a navigation link by setting whatever state it's watching to true.
Probably the simplest way to build a list is to create a new SwiftUI view and wrap the Hello World text in a List: struct StaticListView: View { var body: some View { List { Text("Hello, world!") } } } To add more items to the list, we can just add another line: List { Text("Hello, world!") Text("Hello, SwiftUI!") }
Setting the NavigationLink width and hiding it did the trick for me
List { ForEach(pages) { page in HStack(spacing: 0) { Text("Something") NavigationLink(destination: Text("Somewhere")) { EmptyView() } .frame(width: 0) .opacity(0) } } }
Swift 5, Xcode 11. ZStack works perfect.
var body: some View { NavigationView { List { ForEach(viewModel.currenciesViewModel) { cellViewModel in ZStack { cellViewModel.makeView() NavigationLink(destination: ChooseCurrencyListView()) { EmptyView() } .buttonStyle(PlainButtonStyle()) } } } .navigationBarHidden(true) .navigationBarTitle("", displayMode: .inline) } }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With