Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

App Store style scrolling in iOS

Hi guys. After looking at some of the articles about implementing cover flow, I've come to the conclusion that it would be more trouble than it is worth. Do you know how to implement the slide-rule style scrolling as seen in the app store on an iPhone when browsing screenshots? If someone knows or could point me in the right direction that would be awesome.

4 Answers

This can be done using a UIScrollView (docs) and setting the pagingEnabled to YES.

Just set the frames and add all your UIImageViews as a subviews. Then set the contrentSize equal to the total width of the images and any padding. Paging will automatically make it snap when swiping.

Let me know if you'd like to see some example code.

Wow that's awesome! Some example code would be great if you have the time!

Here's a quick snippet of code (untested), but should help you get the idea. If you want it to work like the App Store does then you'll need to change the width of the scroll view and account for some padding in between the image views.

Gist

We needed that function some months ago and this post really helped us.