开发者

Sidescrolling UI on iPhone

开发者 https://www.devze.com 2023-01-02 07:25 出处:网络
Please lead me in the right direction. I need 开发者_StackOverflowto 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 p

Please lead me in the right direction.

I need 开发者_StackOverflowto 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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消