13
votes

I have a UITableView with Cells that have UIImages as main content. The Table View is paginated, so when I'm near the end of the UITableView I make a new Request to the API and insert the new cells (infinit scrolling).

The problem is that when the data from the API arrives, and I add them to the table view, the scrolling stops completly.

I've tried with

[tableview reloadData]

and

[tableview beginUpdates]
[tableview insertRows...]
[tableview endUpdates]

But the Scrolling animation stops completly in both cases.

2
can you post bit more code ? - Code cracker
did you checked the cellforrowatindexpath after making the new request? - Code cracker
@Codecracker thanks to your comment I rechecked my code and found the problem! Silly mistake from me, I'll post the answer. - 6rod9

2 Answers

48
votes

I just found the problem: After the new data arrived I had a UIRefreshControl calling [self.refreshControl endRefreshing]. And for some reason that method stopped all scrolling animation in the table view.

By adding

if ([self.refreshControl isRefreshing]) {
    [self.refreshControl endRefreshing];
}

the problem was solved.

1
votes

Swift 5:

if self.refreshControl.isRefreshing {
    self.refreshControl.endRefreshing()
}