There is a UIScrollView with scrolling width

 [scrollView setContentSize:CGSizeMake(self.frame.size.width*array.count, self.scrollView.frame.size.height)]; // задаем количество слайдов, 

three UIView to it UIView transition between them is done through the UIPageControl through the delegate method

 - (void)scrollViewDidScroll:(UIScrollView *)scrollView { CGFloat pageWidth = CGRectGetWidth(self.bounds); CGFloat pageFraction = self.scrollView.contentOffset.x / pageWidth; self.pageControl.currentPage = roundf(pageFraction); } 

Everything works, the problem is that I need endless scrolling. For example, from the last scroll to move to the first, and from the first to the last. Tell me, please, how to do this?

  • if you have for example 3 pages 1-2-3. you need to make 5 pages 3-1-2-3-1, and when the scroll reaches the end from one of the sides in the didScroll method, move it to another position of the same element (from 1 to 4, from 5 to 2) - Max Mikheyenko
  • one
    even not so, make 3 pages, start from the second, after scrolling, rearrange elements in places and again show the second page. for example, you start at position 3-1-2 with a scroll on page number 1, if there was a scroll to the right, rearrange 1-2-3 and set the content offset to page 2 - Max Mikheyenko
  • Thanks, interesting idea, I will try. - Victor Mishustin
  • To solve this, I used this library, GBInfiniteScrollView. It's very simple, without dancing with a tambourine. - Victor Mishustin

3 answers 3

Try using iCarousel

  • Thanks, I will try to library this library. - Victor Mishustin

Why not use the UICollectionView with the elements located on the left, there is a recursion of objects even by default, if I remember correctly. It will look more beautiful and take up less resources.

    The scroll should be installed on the middle element (and you need to enable paging). When scrolling is finished scrolling (delegate's scrollViewDidEndDecelerating method) you: - put the current view (first or third) in second place - the second view in free space - scroll to second view (central). No animation - fill the view with new data