I am working on a chat application. Initially, I fetch 100 message only and as the user scroll the messages and come to the first message, I fetch the next 100 message and reload the data. I am maintaining the scroll position by setting the content offset, but in this case, scrolling gets stopped and the user feels a jerk in scrolling. How to maintain the scrolling speed, so that user doesn't know if the table has reloaded.
Asked
Active
Viewed 160 times
1 Answers
0
You need to do it before you arrive at the very bottom. You can use delegate method func tableView(UITableView, willDisplay: UITableViewCell, forRowAt: IndexPath)
to check if you are at 70 percents(might be more or less, you will have to try) of your cell count. Then initiate load next data. Do not forget to mark that you are currently loading, otherwise you will end up with the infinite amount of load calls.

Luzo
- 1,336
- 10
- 15
-
I did that too, but scrolling gets stop and user feels the jerk in scrolling. – Aashish Nagar Oct 23 '17 at 06:12
-
lag might be caused because you are setting content offset explicitly. Remove it and you can try what Igor suggest there https://stackoverflow.com/questions/37614934/uitableview-scrolls-to-top-on-reload , your scroll position should stay intact after reload – Luzo Oct 23 '17 at 06:22