I have a UITableView which populate it cells with a NSFetchedResultsController. Also I use indexPathsForVisibleRows to update visible cells except the one I tapped and edit. But the UI updates all cells with proper calculation except one. If I scroll that tableView then that cell recalculate itself next time it becomes visible.
GIF with the problem: CLICK
There I define the cell to edit and reload Rows for all cells except the one I am editing:
func textFieldDidChangeSelection(_ textField: UITextField) {
let tapLocation = textField.convert(textField.bounds.origin, to: tableView)
guard let indexPath = tableView.indexPathForRow(at: tapLocation) else { return }
pickedCurrency = fetchedResultsController.object(at: indexPath)
let visibleIndexPath = tableView.indexPathsForVisibleRows ?? []
var nonActiveIndexPaths = [IndexPath]()
for index in visibleIndexPath where index != indexPath {
nonActiveIndexPaths.append(index)
}
tableView.reloadRows(at: nonActiveIndexPaths, with: .none)
}
Why the UI updates all cells except one? Can't find the reason...
Here is how I managed to solve my problem. The thing I understood is I should avoid using
tableView.indexPathsForVisibleRowsfor my case since as @ShawnFrank stated it will reload only visible cells: