title: iOS: How To swipe through an image with pagination on
body: <p>Basically, I want to have an app with only one view that has an image on it. I want to be able to swipe left or right and have the first image go out of the view and the second image to come in. The images are the same and I want it to look like they are connected (like scrolling down a rope where the pattern just repeats, but it looks like a constant scroll). I need it to be able to change the image or restart after a series of swipes. I know that I need to turn pagination ON in the UIScrollView, but I am new to iOS and am having trouble. </p>
  
  <p>Ultimately, I want to have the iPhone vibrate every so-and-so swipes (and restart the pattern).</p>
  
  <p>I'm sure that there are a lot of ways to do this (i.e. a TableView) so feel free to just point me in the direction of some references if the answer is tedious to explain.</p>
  
  <p>Thanks!</p>
  
  <p>FOLLOW UP:</p>
  
  <p>I found an Apple example that did very nearly what I wanted to do. I made a lot of adjustments to it, but I'm banging my head against a wall trying to get the images to cycle. Here is what I think is the offending code, but I'm not sure what the solution is, as the ScrollView is functional, it just doesn't reset the center to the current view. Any ideas?</p>
  
  <pre><code>    - (void)layoutScrollImages
  {
          UIImageView *view = nil;
          NSArray *subviews = [scrollView1 subviews];
  
      // reposition all image subviews in a horizontal serial fashion
      CGFloat curXLoc = 0;
      for (view in subviews)
      {
          if ([view isKindOfClass:[UIImageView class]] &amp;&amp; view.tag &gt; 0)
          {
              CGRect frame = view.frame;
              frame.origin = CGPointMake(curXLoc, 0);
              view.frame = frame;
  
              curXLoc += (kScrollObjWidth);
          }
      }
  
      // set the content size so it can be scrollable
      [scrollView1 setContentSize:CGSizeMake((kNumImages * kScrollObjWidth), [scrollView1 bounds].size.height)];
  
  }
  </code></pre>