UItableView load data on scroll

后端 未结 6 722
予麋鹿
予麋鹿 2020-12-24 03:42

In my app I am getting the data from the web-service and I have to display it in UITableView. But the condition here is I have to display only 10 records initially,then once

6条回答
  •  眼角桃花
    2020-12-24 04:30

    In case if some one need it,i was able to solve my problem this way. First thing is you need the server configuration in such a way so that it should return 10 data at a time based on the row which is visible in TableView. This is the tableView delegate which get called and returns the visible cells in tableView

     -(void) tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
        {
            int lastRow=[nameArray count]-1;
            if(([indexPath row] == lastRow)&&(lastRow<[categoryArray count]))  
            {
    
                if(tableView==m_pDetailsTableView)    {
                    savedScrollPosition=lastRow;
                    startCellValue=[NSString stringWithFormat:@"%d",0];
                    endCellValue=[NSString stringWithFormat:@"%d",[nameArray count]+10];
                    [self connectToServer]; //Method to request to server to get more data
                }
            }
        }
    

    savedscrollPosition variable stores the variable as a point where you want to scroll the table view after load of data.

提交回复
热议问题