Insert error unsing Widget.newTableView

Hi

I’m having an error that i cant figure out.
 

Im adding images to a tableview. Those images are captures that i create outside of the table view and then insert then on the table rows.

the error im receiving is in the Capturar.PNG file. it says: 105: bad argument #-2 to ‘insert’ got nil.

The problem is that the table is already created and this error only shows when im scrooling throught it. and there is nothing on my onRowTouch that calls the function onRowRender again. There is no reason for it to try to insert it again is there? If there is why it gives an error? i havent removed the captures (is it a problem with captures?).

ill try to send the parts of my code that are being used. never did it.

function menuLateral.onRowRender( event)

               

local phase = event.phase

   local row = event.row

   

   local groupContentHeight = row.contentHeight

   local groupContentWidth = row.contentWidth

               

               

               

   row.TitRetangulo1 = display.newRect(row,0,0,65,16+2)

   row.TitRetangulo1:setFillColor(0,0,0)

   row.TitRetangulo1.anchorX=0;row.TitRetangulo1.anchorY=0

   row.TitRetangulo1.x = 0

   row.TitRetangulo1.y = 0

   row.params.imagem

   row:insert(row.params.imagem) – THIS LINE AN ERROR

   row.params.imagem.x = 0

   row.params.imagem.y = row.TitRetangulo1.y + row.TitRetangulo1.height

               

   row.rowTitle = display.newText( row, row.params.texto,0,0, 65, 0, “Arquivos/fontes/arial.ttf”, 15 )

   row.rowTitle.x = 2

   row.rowTitle.anchorX = 0;row.rowTitle.anchorY = 0

   row.rowTitle.y = 0

   row.rowTitle:setFillColor( 1,1,1 )

end

[lua]

Now the code that call the rowRender function:

[/lua]

for i = 1,#menuLateralTelas do

   Telas[menuLateralTelas.tipo].TXTs.vetorTelas[i].capture:scale(menuLateral.escala,menuLateral.escala)

   

   local rowHeight = Telas[menuLateralTelas.tipo].TXTs.vetorTelas[i].capture.height*menuLateral.escala

   local rowColor = {

            default = tableViewColors.rowColor.default,

            over = tableViewColors.rowColor.over,

   }

   menuLateral.tableView:insertRow{

            rowHeight = rowHeight,

            rowColor = rowColor,

            lineColor = tableViewColors.lineColor,

            params = {

                        defaultLabelColor=tableViewColors.defaultLabelColor,

                        catLabelColor=tableViewColors.catLabelColor,

                        texto = menuLateralTelas[i],

                        imagem = Telas[menuLateralTelas.tipo].TXTs.vetorTelas[i].capture

            }

   }

end

i uploaded a video showing the error ocurring. Here is the link: 

https://drive.google.com/open?id=1G_ae3T48VpHDuddn_loLfUbX-wLlznMB

Thanks in advance
My best Regards

Probably row.params.imagem is nil for some reason

row.params.imagem --what should this do? maybe you are missing "= something" part? print (row.params.imagem) --you can try this to check if value is nil in console if row.params.imagem then --maybe this might help -row:insert wont run if row.params.imagen is nil row:insert(row.params.imagem) end

Yeah thats the error its giving.
But the image wasn’t nil in the beggining. And if you move the table initially it works fine. I guess only when i move down and up again it gives the message.

I found an easy way to avoid the error by saving the capture into an image. And creating the image inside the table view instead of using the capture. It solved my problem.
So iguess tableview dont work well with captures.
Its probably a problem with how the tableview behaves. My guess is that it keeps updating itself, and the capture end up being removed in the middle at some point.

As i made some tests i noticed that the tableview really remove and recreate its components on movement. And with captures taht arent created on the rowRender function it cant recreate again, all display objetcs must be created insied row render function, and not created externaly and included on the row. Thats why the error happens since my captures where generated externaly and the rowrender removed it and tryed to recreate it.

Probably row.params.imagem is nil for some reason

row.params.imagem --what should this do? maybe you are missing "= something" part? print (row.params.imagem) --you can try this to check if value is nil in console if row.params.imagem then --maybe this might help -row:insert wont run if row.params.imagen is nil row:insert(row.params.imagem) end

Yeah thats the error its giving.
But the image wasn’t nil in the beggining. And if you move the table initially it works fine. I guess only when i move down and up again it gives the message.

I found an easy way to avoid the error by saving the capture into an image. And creating the image inside the table view instead of using the capture. It solved my problem.
So iguess tableview dont work well with captures.
Its probably a problem with how the tableview behaves. My guess is that it keeps updating itself, and the capture end up being removed in the middle at some point.

As i made some tests i noticed that the tableview really remove and recreate its components on movement. And with captures taht arent created on the rowRender function it cant recreate again, all display objetcs must be created insied row render function, and not created externaly and included on the row. Thats why the error happens since my captures where generated externaly and the rowrender removed it and tryed to recreate it.