TableView - dynamic rowHeight

I’m trying to build a list of rows inside my newTableView and it looks like the rowHeight is stuck at a value of 40 px. I did not set the the rowHeight as my understanding is that Corona takes the content of the display row and sizes the height accordingly.

Code is posted below (this is part of a Composer/Storyboard file)

local thisTableScroll local function onLineRowsRender ( event ) local row = event.row local id = row.index -- Create first multi-line text object local options1 = { text = "The quick brown fox jumped over the lazy dog.", x = 0, width = 120, --required for multi-line and alignment font = native.systemFont, fontSize = 18 } local myText1 = display.newText( options1 ) myText1.anchorX = 0 myText1.anchorY = 0 myText1:setFillColor( 0 ) row:insert(myText1) return true end local function populateRows() for i = 1, 20 do thisTableScroll:insertRow { isCategory = false, rowColor = { 1, 1, 1 }, lineColor = { 0.90, 0.90, 0.90 }, } end end function scene:create(event) local group = self.view local navBarHeight = 60 local tabBarHeight = 50 thisTableScroll = widget.newTableView { top = navBarHeight, width = display.contentWidth, height = display.contentHeight - navBarHeight - tabBarHeight, onRowRender = onLineRowsRender, onRowTouch = onRowTouch, listener = scrollListener } group:insert(thisTableScroll) populateRows() end

I’ve also attached a file showing what it looks like.

Thanks for any input in advance!

The tableView widget does not support dynamic row heights.  You have to explicitly state it during the insertRow() call if not it defaults to 40.

If you need to do multi-line text and won’t know the height, you always could render the display object to a temporary value and get it’s height before calling insert row.  Not elegant, but it should work.

Rob

Thanks Rob for the explanation. I was able to create a quick helper function to obtain the height before inserting the row.

The tableView widget does not support dynamic row heights.  You have to explicitly state it during the insertRow() call if not it defaults to 40.

If you need to do multi-line text and won’t know the height, you always could render the display object to a temporary value and get it’s height before calling insert row.  Not elegant, but it should work.

Rob

Thanks Rob for the explanation. I was able to create a quick helper function to obtain the height before inserting the row.