How to make a dynamic row addition when the user has reached the last row of a UITableView?

I have UITableviewone that shows 10 lines currently that are motionless. Now I want to add a function to it. I want to add more than 10 rows to the table when the user reaches the last row UITableview. I mean, I'm currently showing fixed 10 lines in the application.

But now I want to add another 10 lines when the user reaches the last line of the previous one UITableview.

Please give me any suggestions or some sample code to achieve my motive. Thanks in advance.

+4
source share
4 answers

10 ? , 10, , 10.

" " . , 10.

( , " ", , , , .)

:

  • cellForRowAtIndexPath , , , 10
  • 10 , [myTable reloadData]
  • numberOfRowsInSection 10 , cellForRowAtIndexPath 11-20

ps, 10 , , 10 cellForRowAtIndexPath willDisplayCell:forRowAtIndexPath:, .

+6

. , tableView:willDisplayCell:forRowAtIndexPath:, UITableViewDelegate. , . , , . - :

– (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *) cell forRowAtIndexPath:(NSIndexPath *)indexPath 
{
     if(indexPath.row == [self.array count] - 1) //self.array is the array of items you are displaying
     {
          //If it is the last cell, Add items to your array here & update the table view
     }
}

( ) UIScrollView (UITableView UIScrollView), scrollViewDidEndScrollingAnimation: scrollViewDidScroll:. y- , . , , .

,

+15

uitableview uiscrollview. , scrollViewDidEndDecelerating:

 - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
    float endScrolling = scrollView.contentOffset.y + scrollView.frame.size.height;
    if (endScrolling >= scrollView.contentSize.height) 
    {
      // your code goes here
    }
}

" ", , , , .

+12
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return [categoriesList count];
}

categoryList - . reloadData .

+1
source