I found the Table with Toggle will have performance issue when the data is large.
I can reproduce it in Apple demo:
https://developer.apple.com/documentation/swiftui/building_a_great_mac_app_with_swiftui
Replace with a large mock data, for example
database.json
Try to scroll the table, it's not smooth.
I found if I delete the Toggle, the performance be good.
TableColumn("Favorite", value: \.favorite, comparator: BoolComparator()) { plant in
Toggle("Favorite", isOn: $garden[plant.id].favorite)
.labelsHidden()
}
Is this bug in SwiftUI? Any workaround?
My Mac is Intel, not sure it can repro on Apple Silicon
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
I create a simple list, there are two kind of item: conversation and message, if click a conversation, it will expand it's messages.
So there will be some insert and remove updates.
I calculate the difference results and perform the batch update.
displayItems = newDisplayItems
tableView.beginUpdates()
tableView.removeRows(at: IndexSet(removeIndex), withAnimation: [.effectFade, .slideUp])
tableView.insertRows(at: IndexSet(insertIndex), withAnimation: [.effectFade, .slideDown])
tableView.endUpdates()
In most cases, the animation looks fine, but when the mock data is large (> 1000?) and called scrollRowToVisible to scroll to the last row in viewDidAppear, then click some conversations above, the UI broken.
Is there something wrong? Would appreciate help from someone experienced with NSTableView.
Example code
Topic:
UI Frameworks
SubTopic:
AppKit