SwiftUI on iPad: Organize your interface

RSS for tag

Discuss the WWDC22 Session SwiftUI on iPad: Organize your interface

Posts under wwdc2022-10058 tag

2 Posts
Sort by:
Post marked as solved
1 Replies
51 Views
I have a SwiftUI Table on iPadOS that supports multiple selection and contains rows representing documents that can be opened. I want to be able to select multiple rows from edit mode or with keyboard modifiers for batch operations, but a regular tap on a single item should open it and push it onto the navigation stack. Rows are highlighted when I tap on them, but the table's selection isn't modified and I can't figure out how to respond to that action. There's nowhere for me to put a NavigationLink because I'm only providing views for each column and not for the row itself. I could also push onto the navigation stack manually if I could respond to the action, but I don't see any API for doing so. I've tried using .onChange(of: selection) and checking that the selection only contains a single element, but single taps on rows don't modify the selection, and even if they did, this logic would trigger incorrectly when adding the first item to the selection in edit mode for example. Is there something I'm overlooking, or is this not possible with SwiftUI tables currently?
Posted
by jlong64.
Last updated
.
Post not yet marked as solved
2 Replies
182 Views
The new contextMenu(forSelectionType:menu:) implementation is pretty nifty, but as far as I can tell the only views that support it are List and Table. I was wondering if it's possible to support this new behavior with a custom container, and if so -- how?
Posted
by number16.
Last updated
.