After implementing the refresh control I noticed that whenever I used to refresh, it used to append the new data in the array and created duplicity. I thought of a very simple solution which is that we can actually empty our array when refreshing so that we can avoid duplicity.
当您刷新数据(pull to refresh)时,您应该清空array数据并用新数据填充它。你知道吗
简单地说不,没有任何性能问题,您也可以将新的响应分配给您的变量,而不删除结果就像这样:
这是处理这种情况的最佳方法,您最后可以看到它们实现的Google Place API SDK。 这是肯定的,在做了所有的测试用例和分析之后,他们会做任何事情。你知道吗
当您刷新数据(pull to refresh)时,您应该清空
array
数据并用新数据填充它。你知道吗如果你的意思是“分页”加载,你可能应该看看这个大问题。我个人非常喜欢twitter's post关于实施时间表。
另外,应该提到的是,屏幕上的显示数据没有问题,因为
reloadData()
函数只重新加载可见单元格。reload/delete/insertRows
也不需要对UI进行如此繁重的操作。所以,实现它的唯一问题就是屏幕和数据库上数据的一致性。你知道吗我认为最好的方法是分页。在开头提取10或20个数据,并将其保存在数组中,然后加载
tableview
。当用户开始滚动方法willDisplayCell
中的tableview
时,增加页面计数,从服务器获取下一个10或20个数据并将其附加到数组中。你知道吗相关问题 更多 >
编程相关推荐