I parse JSON according to page number and display the response in an UITableView. I calculate the page number like this
But in this calculation sometimes i get wrong page number. When the page number increase then the calculation gives a wrong result. (e.g: page number 3 from 5. It skips the 4). Is there any different way to make a paging with UITableView
Code:
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
if(self.orderListTable.contentOffset.y >= (self.orderListTable.contentSize.height - self.orderListTable.frame.size.height)) {
NSInteger pageNumber = scrollView.contentOffset.y / (scrollView.contentSize.height - scrollView.frame.size.height);
NSLog(@"END %ld", (long)pageNumber);
self.scrollPage = [NSString stringWithFormat:@"%ld", (long)pageNumber];
if (pageNumber == 0) {
[self.orders removeAllObjects];
[self getTheOrderList:self.selectedOrderType page:self.scrollPage];
} else {
if (self.previousScrollPage == pageNumber) {
return;
} else {
[self getTheOrderList:self.selectedOrderType page:self.scrollPage];
}
}
self.previousScrollPage = pageNumber;
}
}