添加新行时 UITableView 停止滚动 [英] UITableView stops scrolling when adding new rows
问题描述
我有一个带有 UIImages 作为主要内容的单元格的 UITableView.表格视图是分页的,所以当我接近 UITableView 的结尾时,我向 API 发出一个新的请求并插入新的单元格(无限滚动).
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).
问题是当来自 API 的数据到达时,我将它们添加到表格视图中时,滚动完全停止.
The problem is that when the data from the API arrives, and I add them to the table view, the scrolling stops completly.
我试过
[tableview reloadData]
和
[tableview beginUpdates]
[tableview insertRows...]
[tableview endUpdates]
但滚动动画在两种情况下都完全停止.
But the Scrolling animation stops completly in both cases.
推荐答案
我刚刚发现问题:在新数据到达后,我有一个 UIRefreshControl 调用 [self.refreshControl endRefreshing]
.由于某种原因,该方法停止了表格视图中的所有滚动动画.
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.
通过添加
if ([self.refreshControl isRefreshing]) {
[self.refreshControl endRefreshing];
}
问题解决了.
这篇关于添加新行时 UITableView 停止滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!