Lazy loading of subViews into a non-paging UIScrol

2019-03-22 02:14发布

I am trying to implement a filmstrip-like UIScrollView that will be populated with thumbnails of catalog pages. Selecting a thumbnail image will cause the main UIScrollView to move to the selected page. The Catalog may contain 100 - 200 pages, and I want to load them lazily only when required.

I have done this in a UIScrollView with paging enabled, but haven't seen anything on the best way to do this in a non-paging scenario. There will be 6 thumbnails visible in the UIScrollView (+ 1 when the view is being scrolled) at any one time. I want to dequeue and reuse the thumbnail's UIView when the view is scrolled, as I am doing in the main UIScrollView (which is a paging scroll view).

Thanks -

Jk

3条回答
疯言疯语
2楼-- · 2019-03-22 02:35

Check out this class..it may proove helpful..

VSScroller

查看更多
We Are One
3楼-- · 2019-03-22 02:51

Check out the scrollview suite sample code from apple. The tiled example can probably be repurposed very easily.

http://developer.apple.com/library/ios/#samplecode/ScrollViewSuite/

查看更多
聊天终结者
4楼-- · 2019-03-22 02:51

I am also going to suggest you take a look at some sample code of Apple, that is, Photo Scroller. If you are a registered iOS developer, you should also take a look at the WWDC10 session about scroll views in iPhone applications.

http://developer.apple.com/library/ios/#samplecode/PhotoScroller/Listings/main_m.html

What you need to do is mimic the behavior of a table view (which is nothing more than a subclass of UIScrollView). What you should mimic is the reuse of the cells. It is pretty easy to implement and will dramatically reduce the memory foot print of your application since you only load the content that is currently visible in the scroll view.

I hope this helps.

查看更多
登录 后发表回答