I have a UITableView that supports multiple selection on Mac. My table view also supports swipe actions. When a row is selected and I swipe on another table view row to expose swipe actions, UITableView discards the current selection for seemingly no reason.
To reproduce:
- Configure a UITableView that allows multiple selection.
- Configure swipe actions.
- Run the app. Select a couple rows (via Command click or shift click).
- Two finger drag on the track pad to expose a swipe action on another row.
- Swipe to hide the swipe actions (not invoking an action).
- UITableView discards the entire selection for no apparent reason.
Also the UITableView discards the selection without even informing the delegate (I have a label displaying the selection count in the UI and it still shows the selection count before UITableView clears the selection when a row is swiped).
I don't want to discard the selection just because a swipe action is exposed. I tried working around the problem by reselecting the rows index paths in -tableView:didEndEditingRowAtIndexPath:
-(void)tableView:(UITableView*)tableView didEndEditingRowAtIndexPath:(nullable NSIndexPath*)indexPath
{
//Swipe action is over..fix the selection:
[self reselectIndexPathsAtTheEndOfSwipeActionEditing]; /
}
But when one of the selected index paths is outside the visible region of the table view scroll position jumps after programmatically reselecting the rows which looks wrong...
Anyone have a workaround for this?