Используйте свойство в контроллере представления, которое будет хранить детали текущего выбранного индекса.
var selectedIndexPath : IndexPath?
В cellForRowAt
метод UITableView
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "CellRID") as! PaymentCell
if selectedIndexPath != nil && indexPath == selectedIndexPath {
cell.btnCheckUnCheck.setImage(UIImage(named: "CheckTerm"), for: .normal)
} else {
cell.btnCheckUnCheck.setImage(UIImage(named: "uncheckTerm"), for: .normal)
}
return cell
}
Изменить ниже методas
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
selectedIndexPath = indexPath
}
func tableView(_ tableView: UITableView, didDeselectRowAt indexPath: IndexPath) {
selectedIndexPath = nil
}
Это не приведет к проблемам с перезагрузкой ячеек.Надеюсь, это поможет.