In UIKit you can select multiple rows of a UITableView by using allowsMultipleSelection - can this be done with the List in SwiftUI?
相关问题
- SwiftUI: UIImage (QRCode) does not load after call
- In a UIViewControllerRepresentable, how can I pass
- How do you preview a view containing a binding to
- SwiftUI: How to drag and drop a contact from Conta
- How create a MonthPicker in SwiftUI?
相关文章
- SwiftUI ForEach 'identified(by:)' is depre
- SwiftUI automatically scroll to bottom in ScrollVi
- Type of expression is ambiguous without more conte
- SwiftUI - Vertical Centering Content inside Scroll
- NavigationView and NavigationLink on button click
- Programmatically detect dark mode in SwiftUI to di
- dyld: Library not loaded SwiftUI when app runs on
- Views compressed by other views in SwiftUI VStack
I found an approach using a custom property wrapper that enables the selection to be modified from a child view using a
Binding
:Here is the source for
BindingList
The only way to get multiple selection in SwiftUI right now is by using
EditButton
. However, that's not the only instance you might want to use multiple selection, and it would probably confuse users if you usedEditButton
multiple selection when you're not actually trying to edit anything.I assume what you're really looking for is something like this:
Below is the code I wrote to create this:
Here is an alternate way that uses a helper I created called
Multiselect
:With the supporting code here:
I created a custom
ToggleStyle
as follows: