Вы можете добиться того же с пользовательской реализацией, как показано ниже
Определить массив из 2 элементов для хранения уникального выбора для каждой секции
var selection = [-1, -1]
Пользовательский методы для обработки выбора пользователя
func setSelection(for index: IndexPath) {
if selection[index.section] != -1 {
//clear the old selection
let cell = getCell(for: IndexPath(row: selection[index.section], section: index.section))
cell.backgroundColor = .white
}
//add new selectoin
let currCell = getCell(for: index)
currCell.backgroundColor = .orange
//save new selection state
selection[index.section] = index.row
}
func getCell(for index: IndexPath) -> UITableViewCell {
let cell = custTableView.cellForRow(at: index)
return cell!
}
setSelection
необходимо вызвать из didSelectRowAt
как
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
setSelection(for: indexPath)
}
Вы также можете использовать массив selection
в любое время, чтобы узнать выбранные индексы ячеек
Вывод:
![enter image description here](https://i.stack.imgur.com/aSozj.png)