UITableView——reloadData与reloadSection性能比较

本文通过实验对比了UITableView的reloadData和reloadSection在不同场景下的性能表现。在数据源不变时,两者性能差异不大,但在数据动态变化时,reloadData更为稳定。同时,文中讨论了部分刷新的适用场景,并提醒开发者不要被经验误导,应根据实际情况选择合适的方法。
摘要由CSDN通过智能技术生成

周五上午,测试,有bug:每次reset模拟器后,第一次进入界面,闪退,第二次进入界面,结果正常。

以下是这个bug的错误日志:

 *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of rows in section 1.  The number of rows contained in an existing section after the update (1) must be equal to the number of rows contained in that section before the update (2), plus or minus the number of rows inserted or deleted from that section (0 inserted, 0 deleted) and plus or minus the number of rows moved into or out of that section (0 moved in, 0 moved out).’


发现刷新列表时,闪退。问题出在:[self.tableViewreloadSections:[NSIndexSetindexSetWithIndex:2]withRowAnimation:UITableViewRowAnimationNone];

这个方法我没用过,从方法名看出,这个方法是局部刷新列表的某个section。但一般我都是用reloadData,刷新整个列表。于是,我把reloadSection改回reloadData,发现这个两个bug都不再出现了。

按道理,使用reloadSection应该没有问题啊,但为什么这里不能使用reloadSection呢?

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值