Hi there… I’m trying to do something like a chat and I need to show the last message at the end of the Table View. In my code I have a Table View with 50 rows in it. I’m using the function scrollToIndex so I can scroll up all the rows and the last row shows up at the bottom of the screen. But something weird happens… The rows scroll up all the way and the last row just goes up to the top of the screen. After I drag a little bit the Table View normalizes and the last row fits in the bottom of the screen.
Heres the code:
display.setStatusBar( display.HiddenStatusBar ) local widget = require( "widget" ) -- create a constant for the left spacing of the row content local LEFT\_PADDING = 10 --Set the background to white display.setDefault( "background", 0.8, 0.8, 0.8 ) --Create a group to hold our widgets & images local widgetGroup = display.newGroup() local list -- Handle row rendering local function onRowRender( event ) local phase = event.phase local row = event.row local params = event.row.params local groupContentHeight = row.contentHeight texto = display.newText(row, "Row " .. row.index, 0, 0, native.systemFont, 40); texto.x= 2\*LEFT\_PADDING texto.anchorX = 0 texto.y = groupContentHeight \* 0.5 end -- Create a tableView list = widget.newTableView { top = 38, width = display.contentWidth, height = display.contentHeight, hideBackground = true, onRowRender = onRowRender, onRowTouch = onRowTouch, } widgetGroup:insert( list ) for i = 1, 50 do list:insertRow { height = 72, rowColor = { default = { 1, 1, 1, 0 }, }, } end list:scrollToIndex( list:getNumRows( ) , 0, onComplete )
Sorry for the poor english.
Thanks