title: How can I make UIScrollView/UIPageControl infinite?
body: <p>I have created a simple image scrolling with <code>UIPageControl</code> and <code>UIScrollView</code>, I have three pages ! so what I need is when user scrolls <code>page 0</code> to left , actually scroll should move  to the <code>page 3</code> and vice versa . I have checked Apple sample code but it was so complicated !, here is my codes :</p>
  
  <pre><code>- (void)setupScrollView {
  
  
      _pageControl.currentPage = 0;
      _pageControl.numberOfPages = 3;
      [_scrollView setContentSize:CGSizeMake(_scrollView.frame.size.width * _pageControl.numberOfPages, _scrollView.frame.size.height)];
      _scrollView.delegate = self;
  
      [self createPageWithImage:_image1 forPage:0];
      [self createPageWithImage:_image2 forPage:1];
      [self createPageWithImage:_image3 forPage:2];
  
  
  }
  
      - (void)createPageWithImage:(UIImageView *)frameImage forPage:(int)page
      {
          UIView *newView = [[UIView alloc] initWithFrame: CGRectMake(_scrollView.frame.size.width * page, 0, _scrollView.frame.size.width, _scrollView.frame.size.height)];
          [newView addSubview: frameImage];
          [_scrollView addSubview: newView];
  
      }
  
  
      - (void)scrollViewDidScroll: (UIScrollView *) sView
      {
  
          CGFloat offset = _scrollView.contentOffset.x;
          CGFloat pageSize = _scrollView.frame.size.width;
  
          int page = floor((offset + (pageSize/2)) / pageSize);
          _pageControl.currentPage = page;
  
  
  
      }
  
  
  
  
  
  - (IBAction)changeThePage
  {
  
      CGRect pageRect = CGRectMake(_pageControl.currentPage * _scrollView.frame.size.width, 0, _scrollView.frame.size.width, _scrollView.frame.size.height);
  
      [_scrollView scrollRectToVisible: pageRect animated: YES];
  }
  </code></pre>