title: Scroll view is not smooth
body: <p>I'm working in a project (<strong>iOS7 &amp; ARC</strong>) in which, I want to display <strong>N number</strong> of images in the scroll view.These Images already stored into sandbox directory. My App has only <strong>landscape orientation</strong> I'm facing a problem that <strong>ScrollView is not smooth, it stuck after 2-3 times scroll</strong> </p>
  
  <p>This is how I configure <code>ScrollView</code> </p>
  
  <pre><code>[self.containerScroll setAutoresizesSubviews:NO];
  self.containerScroll.pagingEnabled = YES;
  self.containerScroll.showsHorizontalScrollIndicator = NO;
  self.containerScroll.showsVerticalScrollIndicator = NO;
  self.containerScroll.scrollsToTop = NO;
  self.containerScroll.maximumZoomScale = 5.0;
  self.containerScroll.minimumZoomScale = 1.0;
  self.containerScroll.delegate = self;
  </code></pre>
  
  <p>I'm maintaining only <strong>three Images</strong> in the <code>scrollView</code> at a time.</p>
  
  <p>I'm loading Images in <code>ScrollView</code> in below method</p>
  
  <pre><code>-(void) loadScrollViewWithPage:(int) page{
  
  if (page &gt;= self.numberOfSlides)
      return;
  
  float image_width;
  float image_height;
  
  if(self.isFromListView){
  
      if(IS_IPHONE5){
          image_width = 568.0f;
          image_height = 320.0f;
      } else{
          // iPhone retina-3.5 inch
          image_width = 480.0f;
          image_height = 320.0f;
      }
  
  }
  else{
      image_width = IMAGE_WIDTH;
      image_height = IMAGE_HEIGHT;
  }
  
  CGFloat xPos = page * image_width;
  UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(xPos, 0.0f, image_width, image_height)];
  imgView.tag = page;
  NSString *imgPath = [self.storageDirPath stringByAppendingPathComponent:[NSString stringWithFormat:@"%d%@", page, Image_Extension_JPG]];
  
  NSFileManager *fileManager = [NSFileManager defaultManager];
  __block UIImage *img = nil;
  if(![fileManager fileExistsAtPath:imgPath]){
      [imgView setContentMode:UIViewContentModeCenter];
      img = [UIImage imageNamed:@"icon-loader.png"];
      [imgView setImage:img];
  }
  else{
      [imgView setContentMode:UIViewContentModeScaleAspectFit];
              dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{
  
                   img = [[UIImage alloc] initWithCGImage:[[UIImage imageWithData:[NSData dataWithContentsOfFile:imgPath]] CGImage] scale:1.0 orientation:UIImageOrientationUp];
  
                          dispatch_async(dispatch_get_main_queue(), ^{
                           [imgView setImage:img];
                  });
  
              });
  }
  
  [self.containerScroll addSubview:imgView];
  img = nil;
  fileManager = nil;
  imgView = nil;
  </code></pre>
  
  <p>}</p>
  
  <p>and this how my <code>ScrollView</code> Delegate methods goes...</p>
  
  <pre><code>- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
  {
      self.containerScroll.scrollEnabled = YES;
  
      float page = self.containerScroll.contentOffset.x/self.view.frame.size.width;
      showingSlide = (UInt16) roundf(page);
  
       if(scrollView == self.containerScroll){
  
          // switch the indicator when more than 50% of the previous/next page is visible
          CGFloat pageWidth = CGRectGetWidth(self.containerScroll.frame);
          NSUInteger pageNo = floor((self.containerScroll.contentOffset.x - pageWidth / 2) / pageWidth) + 1;
  
          // load the visible page and the page on either side of it (to avoid flashes when the user starts scrolling)
          [self loadScrollViewWithPage:pageNo - 1];
          [self loadScrollViewWithPage:pageNo];
          [self loadScrollViewWithPage:pageNo + 1];
  
          // a possible optimization would be to unload the views+controllers which are no longer visible
  
          if(scrollView == self.containerScroll)
          {
              [self.previewTableView reloadData];
              [self.previewTableView setContentOffset:CGPointMake(0, (page*220)+64) animated:NO];
              [self.previewTableView  scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:page inSection:0] atScrollPosition:UITableViewScrollPositionMiddle animated:YES];
  
              [self updateSlideNumber];
              [self flashSlideNumber];
          }
  
           //unload unnecessary imageviews from scroll view
           for (UIView* view in self.containerScroll.subviews) {
               if ([view isKindOfClass:[UIImageView class]] &amp;&amp; view.tag != page &amp;&amp; view.tag != page-1 &amp;&amp; view.tag != page+1) {
                   [view removeFromSuperview];
               }
           }
  
      }
  }
  </code></pre>
  
  <p>Now the problem is smoothness of <code>scrollView</code>. When I start scrolling it scrolls fine but after 2 or 3 (or after any random number) pages scroll, it stuck and after trying 2-3 times only it moves again and I have to swipe hard to scroll. Thanks in advance.</p>