3
votes

This is the first question I have asked here so bear with me


. I've done quite a bit of looking into this but have been unsuccessful in finding a solution that worked so I figured I'd toss it out here.

I am using a UIScrollView to try and display a bunch of UIImageViews.

I have 20 UIImageViews loaded into the Scroll View at any one time. What I'm doing at the moment to show more than just 20 photo's is to have the UIImageViews update with new UIImages every time a certain ContentOffset it reached. Whenever the user scrolls down past a ContentOffset of 95 the Offset is reset to 0 and the new pictures are loaded. I picked a number that gave the illusion of continual scrolling so the user does not see the reloading/resetting of the view. The same thing happens when you scroll upwards past 0.

My problem is that when you flick the UIScrollView (so that it continues to scroll by itself) it seems as if the ContentOffset is not resetting like it's supposed to be. The view itself is resetting properly and for 1 iteration the offset is 0, but in the next iteration ( a split second later ) the offset is up in the 120's or 130's and it's jumping down as if I've reached the end of the next screen.

Anyone have any idea how to properly reset the ContentOffset while the UIScrollView is scrolling?

1
When are you checking the contentOffset? I believe the scroll view delegate's scrollViewDidScroll: method should get called even while scrolling with momentum.Daniel Dickison
I am using the scrollViewDidScroll: delegate method. Inside I am checking the current offset. When it's greater than 95 I swap the photos and reset the offset. This works. But then it sets the offset right back to what it was before.Brenton Morse

1 Answers

1
votes

Apparently the inertia algorithm isn't compatible with what you're doing. Why not let it scroll freely and instead recycle the Imageviews that scroll outside of the visible rect for the ones that appear at the other side? (just like a tableview works)