Is there a way to limit how many items scrolled per swipe in UITableView?

195 Views Asked by At

I am thinking of putting UITableView on it's side to make it a carousel, but I'd like to limit the number of item that gets scrolled for every swipe. Think about the screenshot carousel in Apple App Store, when you swipe, it only scrolls 1 item at a time. Is this doable? Is UITableView the right control to use?

2

There are 2 best solutions below

0
Sascha On BEST ANSWER

You can set pagingEnabled to YES, that way the UIScrollView (or UITableView, as it is a subclass of an UIScrollView) will stop on multiples of the scroll view’s bounds when the user scrolls. Take a look here http://developer.apple.com/library/ios/documentation/uikit/reference/UIScrollView_Class/Reference/UIScrollView.html#//apple_ref/occ/instp/UIScrollView/pagingEnabled

0
MLefrancois On

Try using a UIScrollView to get the desired effect.

This example by David Janes should help you out

http://code.davidjanes.com/blog/2009/09/26/uipagecontrol-uiscrollview/