jeudi 13 septembre 2018

Checkboxes in UITableView State Persistence

So I have a table which contains option cells, each of which has a bound label and check box provided by the BEMCheckbox library. Everything works fine, however, when I select let's say the first three options and scroll down, I find three other adjacent cells selected even though I have yet to encounter them.

I understand this has something to do with the inner workings of UITableView and how cells are basically reused and re-rendered as they are scrolled, but no attempt I make to persist state seems to be working. At the moment I'm trying to store selected IndexPath objects in an array, and in the cellForRowAt I will draw the checkbox as on if the path appears in the array. However, even this doesn't seem to work. Any ideas how to fix it?




Aucun commentaire:

Enregistrer un commentaire