I have a ScrollView control and I see that’s scrollHeight space is very big.
I am changing the scrollHeight value but nothing happening.
I assume that there is a display object on my screen and it’s Y values is very big and it’s hidden so I can’t change the space. (it can be because I am calculating the x and y values dynamically in my code)
And that’s my question: How can I find the issue?
Is there a way that how I can find the all display objects on the screen? Can I find them with a for loop?
Under the hood, a scrollView is a display.newGroup() which has no real bounds. The width and height returned is calculated by drawing a bounding box around all objects.
You could loop over your scrollView._view (the display group) , The _ means it’s supposed to be private and you’re not supposed to access it, but Lua really doesn’t support private members. The _ also means we can change it from _view to something else without letting anyone know. So don’t build access to _view into your program for the long term, but for trouble shooting this you can get away with it.
This is untested but something like:
for i = 1, #scrollView._view do – assuming your scrollView is named scrollView…
print( i, scrollView._view[i].x, scrollView._view[i].y
Under the hood, a scrollView is a display.newGroup() which has no real bounds. The width and height returned is calculated by drawing a bounding box around all objects.
You could loop over your scrollView._view (the display group) , The _ means it’s supposed to be private and you’re not supposed to access it, but Lua really doesn’t support private members. The _ also means we can change it from _view to something else without letting anyone know. So don’t build access to _view into your program for the long term, but for trouble shooting this you can get away with it.
This is untested but something like:
for i = 1, #scrollView._view do – assuming your scrollView is named scrollView…
print( i, scrollView._view[i].x, scrollView._view[i].y