0

I try to Build UITableView That load every time a 5 object and when I notice that the scroll table in the last position I reload table data and this open the table from the top again.

how I can save the position and when table reload back to last cell I see ?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Roei Nadam
  • 1,780
  • 1
  • 15
  • 33

2 Answers2

1

Use the below code before you reload the table data

NSIndexPath *indexPath = [NSIndexPath indexPathForRow:(numberOfRowsInLastSection - 1) inSection:(numberOfSections - 1)];

By the above line you will get the position of last row of table.

Use this code after reloading the tableView

[tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionTop animated:YES];

This will scroll to already saved position.

Balaji Kondalrayal
  • 1,743
  • 3
  • 19
  • 38
0

I find a solution in this post - UITableView , Scroll to bottom on reload?

[postTableView reloadData];

 NSIndexPath* ipath = [NSIndexPath indexPathForRow: oldSkip -1 inSection: 1];
[postTableView scrollToRowAtIndexPath: ipath atScrollPosition: UITableViewScrollPositionTop animated:YES];
Community
  • 1
  • 1
Roei Nadam
  • 1,780
  • 1
  • 15
  • 33