ScrollView not scrolling to bottom

Hi there,

I’m creating a level selection screen by adding many buttons to a scrollview inside a for loop. The button for the last level is on top (and is added first in the loop), and the button for the first level is on bottom (and is added last in the loop)

After adding all the buttons to the scrollview, I am calling levelScroller:scrollTo(“bottom”, { time=0 }) so that the scrollview scrolls to the bottom and the button for the first level becomes visible.

The problem is that the scrollview does not scroll all the way to the bottom. It only scrolls down far enough to make the button for the 2nd level visible, and the button for the first level is below that position.

It’s as if the scrollHeight of the scrollview wasn’t updated when adding the last button, so it doesn’t scroll all the way down to it.

for i = 1, 40 do

    levelButtons[i] = widget.newButton(
            left = display.contentCenterX - (524 / 2),
            top = i * 410,
            id = (41 - i),
            defaultFile = "images/buttons/level.png",
            width = 514,
            height = 218,
            label = "Level " .. (41 - i),
            labelColor = { default={ 1, 1, 1 }, over={ 1, 1, 1 } },
            fontSize = 80,
            onPress = onLevelButtonPress



levelScroller:scrollTo("bottom", { time=0 })

Any help is appreciated, thanks.

i have always faced this problem and i always add an object (any object mostly text) at the bottom of the scroll view and keep its alpha set to 0 so that my real objects are visible and scrollable