Reputation: 5195
I have a UITableView in my application. When the table is scrolled almost to the end, I download more data and reload the table.
If the tableView was scrolling, at the time I call [tableView reloadData];
scrolling stops. How can I achieve effect of not stopping the scroll meanwhile reloadData? I think I need to somehow save scrolling speed and then restore it, but how to do this?
P.D. I really searched this question before asking.
Upvotes: 2
Views: 1865
Reputation: 171
if i am not wrong you are looking for a function call Lazy load. I can recommend you to search SVPullToRefresh here!
Upvotes: 1
Reputation: 2365
Since UITableView
is subclass of UIScrollView
, you can use UIScrollViewDelegate
's scrollViewWillEndDragging:withVelocity:targetContentOffset:
method to determine how far it is supposed to scroll and then after table reload call setContentOffset:animated:
with that target offset (or beginning/ending of tableview if it becomes smaller) to simulate continued scrolling
EDIT: since your targetContentOffset
is probably going to be CGRectZero
, you will have to recalculate it somehow using velocity from the same method
Upvotes: 1
Reputation: 2107
I thing, this method (insertRowsAtIndexPaths:withRowAnimation:
) is the key.
There is a use case and a nice tip described on SO: the use case and the tip.
Upvotes: 2