By receiving data from an API, i need to compose a dynamic form. This in my head translated to a tableView with cells that have labels and input fields.
The task was completed, the cells were dynamically sized depending on the constraints, all was fine. When some input in some cell changed the following code run:
func valueOfFieldWithIDChanged(id: Int, value: String){
formFieldsTable.reloadRows(at: [indexPath,indexPath2], with: .none)
}
This updated my row and the new value was displayed properly after formatting etc.
The issue:
When the forms got bigger and spanned more space than a screenful, essentially making the table scrollable a huge issue occurred. When the table was scrolled even a tiny bit, using reloadRows
made a glitchy table scroll animation.
The answer to that was essentially: DONT use UITableViewAutomaticDimension
in heightForRow
if you're gonna use reloadRows
.
The thing is, some rows have multiline labels or need to be dynamically sized in some way or another. It seems like i have to calculate this by hand but i dont know how. Unless.. i'm missing something? Truly hope i am
EDIT: Someone mentioned in the comments that there are other ways to updating fields without reloading the rows. This might be a way to go about it but i dont know what those other ways are