Resize tableview

Hi all,

What is the best way to resize a tableview? Setting the height and width seem to do absolutely nothing. The tableview returns the set values when asked, but it doesn’t resize.

My app allows orientation change and I therefore need to be able to resize the widget.

Any idea for best solution?

Cheers

Martin

Hi Martin,

Since, as you discovered, tableView doesn’t support basic resizing via .width/.height, you might want to apply a custom mask to the widget (on top of it’s self-masked size) and then, on orientation change, remove the current mask and apply another mask of the appropriate size for that orientation. Unfortunately, this still isn’t “ideal” because the tableView would still be in its original size underneath the smaller mask (whichever orientation would use the smaller mask), so it wouldn’t behave as expected with top and bottom limits on scrolling.

A better option may be to simply remove the tableView each time and recreate it in the desired size, but before doing so, gather the Y position the user was currently at, so you can then auto-jump to that same Y position in the new one.

Hope this helps,

Brent

Hi Brent,

I fear this is a rather bad solution as it’s a heavy table, but I guess I have no choice.

How come it’s made this way?

Cheers

Martin

Tableviews are generally not resizable on a device.   i’ve never seen an app that has resize handles to allow a user to resize one on the fly.  Since they are typically designed to fit the UI they are part of they don’t need to resize dynamically. 

Corona SDK’s widget.newTableView can be destroyed and rebuilt in a single frame cycle so it shouldn’t cause a visual disturbance unless you’re dynamically fetching data from a remote source and not caching it locally.

Rob

Hi Martin,

Since, as you discovered, tableView doesn’t support basic resizing via .width/.height, you might want to apply a custom mask to the widget (on top of it’s self-masked size) and then, on orientation change, remove the current mask and apply another mask of the appropriate size for that orientation. Unfortunately, this still isn’t “ideal” because the tableView would still be in its original size underneath the smaller mask (whichever orientation would use the smaller mask), so it wouldn’t behave as expected with top and bottom limits on scrolling.

A better option may be to simply remove the tableView each time and recreate it in the desired size, but before doing so, gather the Y position the user was currently at, so you can then auto-jump to that same Y position in the new one.

Hope this helps,

Brent

Hi Brent,

I fear this is a rather bad solution as it’s a heavy table, but I guess I have no choice.

How come it’s made this way?

Cheers

Martin

Tableviews are generally not resizable on a device.   i’ve never seen an app that has resize handles to allow a user to resize one on the fly.  Since they are typically designed to fit the UI they are part of they don’t need to resize dynamically. 

Corona SDK’s widget.newTableView can be destroyed and rebuilt in a single frame cycle so it shouldn’t cause a visual disturbance unless you’re dynamically fetching data from a remote source and not caching it locally.

Rob