Search code examples
iosuitableviewpreload

Preloading data from network in UITableView


I have a page that support pagination when loading data from network.

I'm using a UITableview to display list.

I want to preload next page when user scroll near the end of current page.

For example, each page has 10 items. When item 8 is visible in the screen, I shall start loading of next page immediately.

Which delegate method of UITableView is the best choice for this task?


Solution

  • Try the following method, It will get to know the display cell

    - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell
        forRowAtIndexPath:(NSIndexPath *)indexPath
        {
    //      Webservice Call for next 10 display data
        }
    

    Discussion A table view sends this message to its delegate just before it uses cell to draw a row, thereby permitting the delegate to customize the cell object before it is displayed. This method gives the delegate a chance to override state-based properties set earlier by the table view