TableView reloadData() re-rendering bug.

SDK Version: Version 2017.3046 (2017.2.28)

Env: iOS and simulator tested.

step 1. sample run.

 

step 2. scroll down to index 10 and tap “Edit” button.

 

step 3. Not re-rendering one invisible row (index 8). (Not constant)

tableview is an owner draw component. In other words you draw the content.  It is your responsibility to adapt based on user input.

I am not seeing any issues with tableview and I use that a lot in my game.

I think you will get a better response if you actually explain what your issue is and what steps you have taken to resolve it.  Your OP doesn’t scope the problem at all.  You say “tap edit button” but I see no edit button?  You need to include code snippets for each pertinent aspect too. 

For example, why does image 1 not have + icons but image 2 does? you don’t explain this functionality change?  

If you want help then you need to ask the right question.  But if your question is “why doesn’t it work” without scoping the issue you might as well me asking “why is it not raining today”.

I modified the screenshot and attached it again… and,

Actually this is a bug. CoronaLabs side needs to be resolved.

@adrianm i am not good at english myself.

This will solve your problem.  Just replace it over your current tap event

------------------------------------------------------------------ -- onTapEvent ------------------------------------------------------------------ local function onTapEvent( event ) local obj = event.target local id = obj.id if id == "edit" then isEditing = not isEditing if isEditing then txtEdit.text = "Done" else txtEdit.text = "Edit" end local scrollY = tableView:getContentPosition() tableView:deleteAllRows() for k,v in spairs(delRows, function(t,a,b) return t[b] \< t[a] end) do table.remove(\_data, v) if v \< currentSong then currentSong = currentSong - 1 elseif v == currentSong then currentSong = 0 end end clearArray(delRows) for i=1, #\_data do tableView:insertRow{ rowHeight=100, params=\_data[i] } end tableView.\_view.y = scrollY tableView:scrollToY({0, 0}) elseif id == "add" then insertRow() elseif id == "del" then if obj.index == currentSong then -- player stop end table.insert( delRows, obj.index ) tableView:deleteRows( {obj.index}, { slideLeftTransitionTime=200, slideUpTransitionTime=200 } ) end return true end

@adrianm Thanks for your reply. and it’s worked. thank you.

@coronalabs TableView still need improvement. Please fix it and improve it.

Can you be more specific about how you would like to see tableViews improved?

@Rob, from what I can tell it is rows that are on the boundary of being culled that are not redrawn when you call reloadData(). Lets say screen height is 960px, I would imagine the cull area is +50px top and bottom. It is rows in that cutoff area that are not redrawn.

My (quick) fix was to remember the offset, drop every row and rebuild and scroll to offset - not ideal with hundreds of rows

I also noticed that scrollToY() was not behaving correctly - actually not working at all so I had to get around it like this

tableView.\_view.y = scrollY -- set any offset here tableView:scrollToY({0, 0})

That bug should have been fixed in a daily build 3043.

Rob

@adrian thank you so much.

 

@rob I tested Version 2017.3061 (2017.3.21)

but not fixed.

Which bug Rob? I’m running 3049 so if it was fixed in 3043 it either regressed or the fix doesn’t always work.

tableview is an owner draw component. In other words you draw the content.  It is your responsibility to adapt based on user input.

I am not seeing any issues with tableview and I use that a lot in my game.

I think you will get a better response if you actually explain what your issue is and what steps you have taken to resolve it.  Your OP doesn’t scope the problem at all.  You say “tap edit button” but I see no edit button?  You need to include code snippets for each pertinent aspect too. 

For example, why does image 1 not have + icons but image 2 does? you don’t explain this functionality change?  

If you want help then you need to ask the right question.  But if your question is “why doesn’t it work” without scoping the issue you might as well me asking “why is it not raining today”.

I modified the screenshot and attached it again… and,

Actually this is a bug. CoronaLabs side needs to be resolved.

@adrianm i am not good at english myself.

This will solve your problem.  Just replace it over your current tap event

------------------------------------------------------------------ -- onTapEvent ------------------------------------------------------------------ local function onTapEvent( event ) local obj = event.target local id = obj.id if id == "edit" then isEditing = not isEditing if isEditing then txtEdit.text = "Done" else txtEdit.text = "Edit" end local scrollY = tableView:getContentPosition() tableView:deleteAllRows() for k,v in spairs(delRows, function(t,a,b) return t[b] \< t[a] end) do table.remove(\_data, v) if v \< currentSong then currentSong = currentSong - 1 elseif v == currentSong then currentSong = 0 end end clearArray(delRows) for i=1, #\_data do tableView:insertRow{ rowHeight=100, params=\_data[i] } end tableView.\_view.y = scrollY tableView:scrollToY({0, 0}) elseif id == "add" then insertRow() elseif id == "del" then if obj.index == currentSong then -- player stop end table.insert( delRows, obj.index ) tableView:deleteRows( {obj.index}, { slideLeftTransitionTime=200, slideUpTransitionTime=200 } ) end return true end

@adrianm Thanks for your reply. and it’s worked. thank you.

@coronalabs TableView still need improvement. Please fix it and improve it.

Can you be more specific about how you would like to see tableViews improved?

@Rob, from what I can tell it is rows that are on the boundary of being culled that are not redrawn when you call reloadData(). Lets say screen height is 960px, I would imagine the cull area is +50px top and bottom. It is rows in that cutoff area that are not redrawn.

My (quick) fix was to remember the offset, drop every row and rebuild and scroll to offset - not ideal with hundreds of rows

I also noticed that scrollToY() was not behaving correctly - actually not working at all so I had to get around it like this

tableView.\_view.y = scrollY -- set any offset here tableView:scrollToY({0, 0})

That bug should have been fixed in a daily build 3043.

Rob

@adrian thank you so much.

 

@rob I tested Version 2017.3061 (2017.3.21)

but not fixed.

Which bug Rob? I’m running 3049 so if it was fixed in 3043 it either regressed or the fix doesn’t always work.