0
votes

I'm having a little issue with scrollview pagination.

My intention is to have 3 pages visible on screen and when I scroll right only on page is scrolled, following the example below, scrolling right will display page 2, 3 and 4 on screen:

scrollview

However I don't know how to display mutiple pages at the same time, at the moment I have it like this:

now

Obviously like this is not what I want.

To achieve the desired functionality I tried making the scrollview's frame the size of the page I want (1/3 of the screen width) and setting the clipToBound to NO so the other pages are visible. This indeed shows 3 pages in the screen; however since the scrollview frame is only 1/3 of the screen I can only swipe in that area, I would like the swipe area to be the whole screen width.

2

2 Answers

2
votes

You're on the right path. Now you can try manipulating UIPanGestureRecognizer of your scrollView, say, re-attaching it to scrollView's superview.

Alternatively, take a look at iCarousel, it can be perfectly customized to suit your needs.

0
votes

My solution in the end was the following:

  • I took my initial approach.
  • I disabled the scrollview's scrollEnabled property.
  • Added swipe gesture recognisers to the scrollview.
  • When the gesture is made I modify the scrollview's contentOffset to move 320/3 pixels to the right or left.