title: Problem with scrollViewDidScroll delegate method and updating the UI
body: <p>I have a scroll view and i am implementing lazyload with page control. I have taken the pagecontrol sample program by apple.</p>
  
  <p>I load 8 thumbnails in every page and the thumbnails themselves are fetched from the network and updated on the UI. The image views are already present in the UI. In my viewDidScroll method i calculate the page number and then update the other pages above and below it as follows:</p>
  
  <pre><code>BOOL isScrollingDown = verticalScrollView.contentOffset.y &gt; _previousContentOffsetY;
  
  _previousContentOffsetY = verticalScrollView.contentOffset.y;
  
  CGFloat pageHeight = verticalScrollView.frame.size.height;
  
  int scrollingToPageNum = isScrollingDown ? (ceil((verticalScrollView.contentOffset.y - pageHeight) / pageHeight) + 1) : (floor((verticalScrollView.contentOffset.y - pageHeight) / pageHeight) + 1);
  int page = floor((verticalScrollView.contentOffset.y - pageHeight / 2) / pageHeight) + 1;
  
  [self loadPage:(page-1)];
  [self loadPage:(page)];
  [self loadPage:(page+1)];
  
  /* Unloading the pages not seen in the view is done here*/
  if (!(isScrollingDown) &amp;&amp; scrollingToPageNum &gt;1) {
      [self unloadPages:page-2];
  }else {
      [self unloadPages:page+2];
  }
  </code></pre>
  
  <p>The UI is too slow and the user experience is very bad. I want to know how can i make the UI more responsive. </p>
  
  <p>Some other questions are:
  1) I have a class which downloads the images and the calling class implements the delegate for the downloader class. Once the image is downloaded the delegate method is called to update the UI. Does this slow down the responsiveness of the UI? How can this be avoided?
  2) What is a optimal way to implement downloading of images and updating the ui without having the UI become unresponsive?</p>
  
  <p>EDIT:
  I am open to ideas on how to best improve and implement this solution.
  I am not creating a thread explicitly but i am using NSURLConnection in async mode, and when data is retrieved the delegate method is called to update the UI.</p>