0

I want to create table view in which paging is required but i want an extra feature like if one cell is added to bottom then one cell will be removed to top

for example

if table have 100 rows and user scroll to bottom app call to server and load another 20 rows at bottom and on same time 20 rows from top will be removed.

if user scroll to top then app call to server and load 20 cell to top and remove 20 cell to bottom.

in short anyhow table have 100 cells only depending on scroll direction cell will be added on top or bottom

3 Answers3

1

To get Extra Feture

  1. You have to maintain data states to get successively record for new 20 on scroll to down or to get old 20 records on scroll up.
  2. A data source array with capacity of 20 items.
  3. On scroll to down last row/scroll to up first row prvious items array replaced by new getted items. 4.Reload tableView.

It will be updated tableview with new 20 items.

abrar ul haq
  • 379
  • 2
  • 14
0

You can maintain the offset and limit for your number of results. Based on the previous offset, you can ask for the next set of results to load in the tableview.

And you can hit API to load result in willDisplayCell:forRowAtIndexpath method of UITableView when the indexPath.row is greater than or equal to your number of results while scrolling down and while scrolling up you can check for indexpath.row == 0 to hit the api to produce previous 20 results.

Vikas Dadheech
  • 1,562
  • 8
  • 23
0

What you are looking for is "Infinite Scroll" A Quick Search brought me following results:

Community
  • 1
  • 1