Note that there are some explanatory texts on larger screens.

plurals
  1. PONeed sample code to implement Paging Based UIScrollView
    text
    copied!<p>I am new to iOS development. Can anyone give me a working sample project/ tutorial of paging based scrollview? I need to load more data in my table view from a webservice as user scrolls down. I have spent a lot of time, but could not find anything that suits my need. Any help will be greatly appreciated.</p> <p>I was able to figure out the solution of my problem. Now I am trying to detect scroll up and down based on the y offset difference. The problem is it always reads the drag to be downwards even if it is upward. This is how I am trying to detect the scroll direction:</p> <pre><code>- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate { CGPoint scrollOffSet = scrollView.contentOffset; NSLog(@"Current Content offset: , y = %f", scrollOffSet.y); NSLog(@"Previous offset , y = %f", self.previousYOffset); if(scrollOffSet.y &gt; self.previousYOffset) { self.previousYOffset = scrollOffSet.y; NSLog(@"Scrolled Down"); self.nextPageNumber++; //Here I send the request to fetch data for next page number } else { NSLog(@"Scrolled up"); self.previousYOffset = scrollOffSet.y; } } - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView { CGPoint scrollOffSet = scrollView.contentOffset; NSLog(@"Current Content offset: y = %f", scrollOffSet.y); } </code></pre> <p>The problem is: either i scroll up or down, it will always display "scrolled down", thus it goes to fetch data for next page number even if it was not intended to request. Plus, the y offset positions it returns on up/down scroll are also very confusing. Please guide me how to accurately detect an upside scroll?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload