Post

Replies

Boosts

Views

Activity

Catalyst - Impossible to pre-select multiple cells of an UITableView under macOS
Description: In an iOS / iPad / tvOS / macOS application, under macOS it's impossible to pre-select several cells of the same UITableView. Visually only one cell is checked and the tableView.indexPathsForSelectedRows property has always only one element. Instruction: Create a UITaleView with custom cell and several sections tableView.allowsMultipleSelection = true In the custom cell, overload setSelected to show a .checkmark or .none In awakeFromNib of the custom cell define selectionStyle to .none In cellForRowAt of the tableview define cells to pre-select, example first cell of each section: 		if (indexPath.row == 0) { 						tableView.selectRow(at: indexPath, animated: false, scrollPosition: .none) 				} else { 						tableView.deselectRow(at: indexPath, animated: false) 				} > Run Expected result: Cells visually selected AND indexPathsForSelectedRows reflecting this selection Obtained result: Only the last cell called by tableview.selectRow is selected and present in the property indexPathsForSelectedRows Did you find a solution to have cell preselected and have property indexPathsForSelectedRows representing the display ? Thanks for your help !
3
0
642
Jun ’20