Working With Scrollview

I have a game that uses a scrollview. When the game first loads the scrollview works perfectly. During the game though sometimes an image will scroll off screen and then it causes the scrollview to no longer scroll in the correct region. For example I have a scrollview that is say 1500px high when I scroll an image off the screen the scrollview will only scroll to say 1200px. Is there a way to scroll an image off the screen without the scrollview changing?

Anyone ever run into this problem?

Are you noticing this in the simulator, device, or both?  It might be related to the maximum texture size supported by the particular hardware you’re using.  For example, if you have someone type text into a native textbox, they can type a very long block of text that scrolls on for ages, but if you then convert that to a non-native, Corona-based text object and stick it in a scrollview it will be cut off after a certain length because the text is now rendered as a bitmap image subject to the largest texture size limit of the device.  On some older devices that’s only 1024 pixels, on more recent devices it’s 2048x2048.  On an iPad 3 I believe it is 4096 pixels.  Not sure what it is on a desktop running the simulator.

I’m noticing this on the both the simulator and 3 test devices. Notice the image below. The first image is how the game starts (the scrollview is scrolled all the way to the bottom). The second image is what happens when I start moving some images and the user tries to scroll back to the bottom. The 3rd is what happens when I repeat step 2 again. Do you see how the scrollview seems to be getting shorter every time?

Hmm. That is strange.  If cutting off the image at exactly the same place on the simulator and all devices then it’s probably not a hardware texture limit.  The next step I would try would be to create the simplest version of your code that has an image of the same size inside a scrollview.  If it exhibits the same problem then you’ve got a great sample to upload a bug report with.  If it doesn’t have the problem then you at least know there’s something else going on.  Maybe it has to to with the other images you are moving around?  Hard to say without seeing some code, unfortunately.

I found the issue and was able to work around it, not sure if it’s an actual fix or not. Anyways what was happening is I would used 2 images and scroll them downward across the reel simulate the sloe machine reels spinning. Once the bottom most image was out of sight I would move it back up to the top of the 2nd image and they would just play a game of leapfrog. What was happening was the images were hanging off the bottom of the scrollview and the scroll view would then freak out about this overlap and behave funny. So what I did was extend the bottom of the bg image down below the max possible hangoff point of the reels. I then set the scrollheight of the scrollview to the correct height and everything seemed to work just fine.

Anyone ever run into this problem?

Are you noticing this in the simulator, device, or both?  It might be related to the maximum texture size supported by the particular hardware you’re using.  For example, if you have someone type text into a native textbox, they can type a very long block of text that scrolls on for ages, but if you then convert that to a non-native, Corona-based text object and stick it in a scrollview it will be cut off after a certain length because the text is now rendered as a bitmap image subject to the largest texture size limit of the device.  On some older devices that’s only 1024 pixels, on more recent devices it’s 2048x2048.  On an iPad 3 I believe it is 4096 pixels.  Not sure what it is on a desktop running the simulator.

I’m noticing this on the both the simulator and 3 test devices. Notice the image below. The first image is how the game starts (the scrollview is scrolled all the way to the bottom). The second image is what happens when I start moving some images and the user tries to scroll back to the bottom. The 3rd is what happens when I repeat step 2 again. Do you see how the scrollview seems to be getting shorter every time?

Hmm. That is strange.  If cutting off the image at exactly the same place on the simulator and all devices then it’s probably not a hardware texture limit.  The next step I would try would be to create the simplest version of your code that has an image of the same size inside a scrollview.  If it exhibits the same problem then you’ve got a great sample to upload a bug report with.  If it doesn’t have the problem then you at least know there’s something else going on.  Maybe it has to to with the other images you are moving around?  Hard to say without seeing some code, unfortunately.

I found the issue and was able to work around it, not sure if it’s an actual fix or not. Anyways what was happening is I would used 2 images and scroll them downward across the reel simulate the sloe machine reels spinning. Once the bottom most image was out of sight I would move it back up to the top of the 2nd image and they would just play a game of leapfrog. What was happening was the images were hanging off the bottom of the scrollview and the scroll view would then freak out about this overlap and behave funny. So what I did was extend the bottom of the bg image down below the max possible hangoff point of the reels. I then set the scrollheight of the scrollview to the correct height and everything seemed to work just fine.