I have a TableView with several rows, in the onTouch event of each row, i show an alert with the options “Move Up” and “Move Down”, that moves the tapped row.
To do that, i switch the position of the rows on the table from which the TableView takes what is to be show. Like this:
for k,v in pairs(savedTable) do --this if is to find the touched row if (v.code == row.params.code) then local temp = savedTable[k] savedTable[k] = savedTable[k-1] savedTable[k-1] = temp break end end tableView:reloadData( )
I’m saving that “savedTable” in a json file.
Thing is, the reloadData() does nothing here. But if i relaunch/restart the project/app, the tableView is loaded with the changed positions.
If i print the savedTable before and after the for, i see that the position of the row has changed.
I change the text of the rows in a similar way, and the reloadData() works. Why it does not work for moving the rows? As i said, the code is moving then, the reload is just not updating the tableView.
I just want to be able to move the rows up or down, is there another way to do this?
Thanks