-1

is there any way to do like Facebook loading that i have one array having 100 objects and on screen 10 cell display.what i want is when i scroll want loading at footer and another 10 data should come and so on...i tried too much but couldn't find this. Data is come from WebService and i am taking it to an array.

Also is this possible that when i scroll and goes to bottom of the tableview it automatically display 10 new cell without reload all table.

i tried this but not success

 if (indexPath.row == [newsArray count] - 1)
            [self News_WS_Called];
rmaddy
  • 298,130
  • 40
  • 468
  • 517
Jekil Patel
  • 403
  • 4
  • 17

1 Answers1

0

I achieved this by using UIScrollViewDelegate's scrollViewDidScroll method. I basically see if the view is scrolled to the bottom and then call the method that handles fetching more, appending to data source and reloading the tableview. Here's a very basic example:

-(void)scrollViewDidScroll:(UIScrollView *)scrollView
{    
    CGRect mainRect = [[UIScreen mainScreen] bounds];
    if(scrollView.contentOffset.y > scrollView.contentSize.height - mainRect.size.height){
      // at the bottom of the scroll view
       [self News_WS_Called];
    }
}

Something things to consider is that you will need some kind of mutex so that the reload / fetch code does not repeatedly get called or gets called when there is nothing on the table view.

jhk
  • 250
  • 3
  • 13
  • this code will working are you sure brother i have doubt because data is already come in array(web service is already called in view will appear method).is there any need to call web service again? – Jekil Patel Sep 05 '14 at 05:06
  • I am not sure what your method "News_WS_Called" does.. You will need to call the web service again because you need to fetch the next set of items with the give LIMIT and OFFSET. – jhk Sep 05 '14 at 22:01