views:

329

answers:

1

I'm creating a comicbook-like application. I'm using a UIScrollView with paging enabled to display the hi-res full-screen images (the app works similar to Photos.app but with zooming disabled). The final product will have nearly 200 images that need to be paged through by the user. How do I go about setting up the UIScrollView for such a large number of pages?

This would be fairly easy to accomplish with just straight UIViews, but the "feel" of the UIScrollView is just so much nicer with the bounce, etc that I think it adds more value to my app. How should I approach making it work?

+1  A: 

Checkout Apple's sample code for PageControl. It shows you how to use a UIScrollView and UIPageControl to cycle through view controllers (just like the photo app). Each page is loaded only as needed.

Basically to achieve lazy loading you start off with an array of empty view controllers. Then as you scroll you load only the current page's view controller as well as the previous and next ones so that scrolling appears smooth. Just look over the sample project, it's fairly short and simple to follow. It should at least get you started. The UIScrollView will tell the appropriate controller when to load itself. It is then the controller's responsibility to load its content (in your case an image).

Good luck.

Nebs
I looked at that sample project some time back and for some reason I seemed to remember it didn't lazy load. Clearly, I was mistaken. Thank you!
Charles S.