I have a SwiftUI List with an HStack containing two Buttons.
If I tap either button, or elsewhere in the cell, the entire cell highlights and actions for both Buttons are fired off.
I can't find where this is documented, but have found that adding
.buttonStyle(BorderlessButtonStyle())
to the List prevents this behavior - tapping individual buttons fire their individual actions as expected.
Is this an expected behavior?
Below is my example without the workaround applied:
struct ContentView: View {
var body: some View {
List {
HStack {
Button(action: {
print("button 1 tapped")
}) {
Text("One")
}
Button(action: {
print("button 2 tapped")
}) {
Text("Two")
}
}
}
}
}
Thanks!
Post
Replies
Boosts
Views
Activity
I have a non trivial application that currently uses a UITableView to display numerous different types of cells.
I'm working on a refactor, and have been attempting to use SwiftUI with List. My concern is that this may not be fully ready for the types of things I want to do in a high volume application.
There are some basic things still missing from List that were in UITableView, like pull to refresh and custom swipe actions. I can write custom implementations, but I've started thinking more about the future of UIKit for lists vs SwiftUI. Apple is continuing to improve upon UICollectionView in particular, and it has a lot more customizability.
I'm wondering - for non trivial lists, is UIKit with SwiftUI cells the preferred way to go? Where exactly does SwiftUI List fit? Is it still a work in progress that will eventually have parity with UIKit counterparts?
Thanks!
Is it possible to create an asset query with fetchAssets(in:options:)
(or any other method) that searches the 'People' album for a specific name? I have never been able to access it, as I don't believe it is actually a Library.
Thanks!