tags:

views:

32

answers:

1

Please lead me in the right direction.

I need to provide user with small text centered on the iPhone screen. User can make quick scroll left or right in order to get the next or previous text. There can be hundreds of such text pieces. The process itself is similar to Photo application sidescrolling but much simple, no zoom.

As far as I can understand I need to use UIScrollView class, then call hundreds of addSubviews? Is it the optimal way or I should always keep 3 subviews and replace them on the fly?

What kind of tricks should be used to achieve the "scroll and center" effect?

Thanks

A: 

You could use a UIScrollView with pagingEnabled = YES for the "scroll and center" effect, I guess.

Then only add the subviews that you're actually displaying, otherwise you'll run out of memory very quickly.

In the UIScrollViewDelegate, in -scrollViewDidScroll: you can get the current contentOffset and determine which subviews you need to add and which ones can be removed.

Thomas Müller
@Thomas Müller: MThere will be only 1 subview at each given time, but I guess I need to load next and previous also to accomplish the quick scroll? Thanks
Michael
Just test it, you might not have to do that. It could be sufficient to only have one or two subviews at any one time.
Thomas Müller