Hello,
I already posted about this in another thread but I found out the problem has a complete different nature, so I’ll restart the conversation with what I realized the issue to seem to be:
I have a tableView and below it (Y axes) two buttons, one adds a row the other the delete a row - just the last row on the list. And this needs to stay this way for design.
Adding row after row obviously the tableview ‘grows’ and the from the 5th on rows are off render.
So, when I push the delete button I want the tableview to scroll up to the last row and THEN have this last deleted (it’s needed for visual interaction consistency).
So I’m using this function to handle the touch of the deleteLastRow button:
local function minusAll (event) if event.phase == "began" then beganTime1 = event.time elseif event.phase == "ended" then endedTime1 = event.time if (endedTime1 - beganTime1) \<= 800 then elseif (endedTime1 - beganTime1) \> 800 and tableView:getNumRows() \> 0 then indexDel = tableView:getNumRows () -- variable set to the index to scroll to and index of row to delete (both last row) tableView:scrollToIndex ( indexDel - 1, 150, function () timer.performWithDelay( 150, function () tableView:deleteRow (indexDel) end) end) end end return true end
If run on simulator everything is smooth and no error occurs, but if tried on device much more often than not it fails to delete the row.
So I tried to add locks to the scrolling (tableview:isLocked = true) and remove them after the transition is over, eliminate bounce, even having not a scrolling function at all…
But nothing works: sometimes it scrolls to last index and deletes, at times it scrolls but does not delete, sometimes it doesn’t even scroll.
And this happens ONLY on devices. Sometimes I spotted a ‘warning - rows cannot be deleted whilst tableview is scrolling’ on the simulator debugger, which leads me to think there’s an asynchronous somewhere that makes the tableview trying to delete the row while the scrolling is still going on. But If you notice in my code I set a delay to make the deletion start way AFTER the scolling has occourred.
So what’s going on here? how I do I tackle this issue??
Thanks for the attention!!!