Ok I got simple sample that can be run with newProject blank file and copy pasted into main below.
I have scrollToY for when simulator is first opened, as well as when a row is pressed. Scrolling when a row is pressed could take some getting used to, but of course feel free to modify for your own tests. I prefer it over restarting the simulator all the time.
I’m creating the table and calling scrollToY immediately afterwards.
Two issues I wanted to point out, when using scrollToY:
-
Sometimes “category 1” blinks a lot before appearing. Might have to fidget with the tests, such as scrolling away to allow re-rendering, a little to see this clearly.
-
Sometimes the regular rows struggle to keep up with rendering, and the rows on the bottom half of the screen can be seen not being loaded yet and is all blank space
Any ideas on how to deal with these issues please
[lua]
local composer = require( “composer” )
local widget = require( “widget” )
function listRowRender( event )
local row = event.row
if row.params ~= nil and row.params.title ~= nil then
local rowTitle = display.newText( row.params.title, 0, 0, 280, 0, “Arial”, 14 )
rowTitle.anchorX = 0
rowTitle.x = 40–70
rowTitle.anchorY=0.5
rowTitle.y = row.contentHeight/1.5
rowTitle:setTextColor( 0,0,0 )
row:insert(rowTitle)
end
print(list:getContentPosition())
end
function listRowTouch( event )
list:scrollToY{y = -2800, time = 0}
end
function createTable()
list = widget.newTableView
{
top = 44,
width = 341,
height = display.contentHeight - 88,
left = -19,
maskFile = “myResource/mask-320x448.png”,
onRowRender = listRowRender,
onRowTouch = listRowTouch
}
populateTable()
end
function resetTable()
if list ~= nil then
list:removeSelf()
list = nil
end
createTable()
list:scrollToY{y = -2864, time = 0}
end
function populateTable()
list:insertRow{
rowHeight = 42,
isCategory = true,
params = { title = “Category1”}
}
for i = 1, 66, 1 do
list:insertRow{
rowHeight = 42,
isCategory = false,
params = { title = “row”}
}
end
list:insertRow{
rowHeight = 42,
isCategory = true,
params = { title = “Category2”}
}
for i = 1, 1111, 1 do
list:insertRow{
rowHeight = 42,
isCategory = false,
params = { title = “row”}
}
end
end
resetTable()[/lua]